Skip to content

Commit

Permalink
fix(@schematics/angular): change extends from tsconfig.base.json
Browse files Browse the repository at this point in the history
…to `tsconfig.json`

Closes: #18534
  • Loading branch information
alan-agius4 committed Aug 17, 2020
1 parent 9511f82 commit f3d54ee
Showing 1 changed file with 4 additions and 6 deletions.
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

0 comments on commit f3d54ee

Please sign in to comment.