Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export default function (): Rule {
return (host, context) => {
const logger = context.logger;

const tsConfig = new JSONFile(host, 'tsconfig.json');
const files = tsConfig.get(['files']);
const files = new JSONFile(host, 'tsconfig.json').get(['files']);
if (!(Array.isArray(files) && files.length === 0)) {
logger.info('Migration has already been executed.');

Expand All @@ -51,16 +50,15 @@ export default function (): Rule {
// Iterate over all tsconfig files and change the extends from 'tsconfig.base.json' to 'tsconfig.json'.
const extendsJsonPath = ['extends'];
for (const path of visitExtendedJsonFiles(host.root)) {
const tsConfigDir = dirname(normalize(path));
let tsConfigJson;

try {
tsConfigJson = new JSONFile(host, path);
const tsConfigDir = dirname(normalize(path));
const tsConfigJson = new JSONFile(host, path);
const extendsValue = tsConfigJson.get(extendsJsonPath);

if (typeof extendsValue === 'string' && '/tsconfig.base.json' === resolve(tsConfigDir, normalize(extendsValue))) {
// tsconfig extends the workspace tsconfig path.
tsConfig.modify(extendsJsonPath, extendsValue.replace('tsconfig.base.json', 'tsconfig.json'));
tsConfigJson.modify(extendsJsonPath, extendsValue.replace('tsconfig.base.json', 'tsconfig.json'));
}
} catch (error) {
logger.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ describe('Migration to remove "Solution Style" tsconfig', () => {
createJsonFile(tree, 'tsconfig.json', { files: [] });
createJsonFile(tree, 'tsconfig.base.json', { compilerOptions });
createJsonFile(tree, 'tsconfig.common.json', { compilerOptions });
createJsonFile(tree, 'src/tsconfig.json', { extends: './../tsconfig.json', compilerOptions });
createJsonFile(tree, 'src/tsconfig.base.json', { extends: './../tsconfig.json', compilerOptions });
createJsonFile(tree, 'src/tsconfig.json', { extends: './../tsconfig.base.json', compilerOptions });
createJsonFile(tree, 'src/tsconfig.base.json', { extends: './../tsconfig.base.json', compilerOptions });
createJsonFile(tree, 'src/tsconfig.tsc.json', { extends: './tsconfig.base.json', compilerOptions });
createJsonFile(tree, 'src/tsconfig.app.json', { extends: './../tsconfig.common.json', compilerOptions });
createJsonFile(tree, 'src/tsconfig.spec.json', { extends: './../tsconfig.json', compilerOptions });
createJsonFile(tree, 'src/tsconfig.worker.json', { extends: './../tsconfig.json', compilerOptions });
createJsonFile(tree, 'src/tsconfig.spec.json', { extends: './../tsconfig.base.json', compilerOptions });
createJsonFile(tree, 'src/tsconfig.worker.json', { extends: './../tsconfig.base.json', compilerOptions });
});

it(`should rename 'tsconfig.base.json' to 'tsconfig.json'`, async () => {
Expand Down