From 0a1e82210d18baf0575e4b2b30ac0a39cb7c8567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Thu, 5 May 2022 15:05:16 +0100 Subject: [PATCH] fix(angular): expand extends property when reading nx.json in the angular cli adapter (#10165) --- packages/nx/src/adapter/ngcli-adapter.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/nx/src/adapter/ngcli-adapter.ts b/packages/nx/src/adapter/ngcli-adapter.ts index e885a643a4381..99a733e590940 100644 --- a/packages/nx/src/adapter/ngcli-adapter.ts +++ b/packages/nx/src/adapter/ngcli-adapter.ts @@ -38,6 +38,7 @@ import { RawWorkspaceJsonConfiguration, WorkspaceJsonConfiguration, } from '../config/workspace-json-project-json'; +import { readNxJson } from '../generators/utils/project-configuration'; export async function scheduleTarget( root: string, @@ -261,10 +262,17 @@ export class NxScopedHost extends virtualFs.ScopedHost { }; const readNxJsonFile = () => { - if (overrides?.nx) { - return overrides.nx; - } - return readJsonFile('nx.json'); + let nxJson = overrides?.nx ? overrides.nx : readJsonFile('nx.json'); + + return nxJson.pipe( + map((json) => { + if (json.extends) { + return { ...require(json.extends), ...json }; + } else { + return json; + } + }) + ); }; return super.exists('nx.json' as Path).pipe( @@ -599,9 +607,7 @@ export class NxScopeHostUsedForWrappedSchematics extends NxScopedHost { // we have to add them into the file. const createdProjectFiles = findCreatedProjects(this.host); const deletedProjectFiles = findDeletedProjects(this.host); - const nxJsonInTree = nxJsonChange - ? parseJson(nxJsonChange.content.toString()) - : parseJson(this.host.read('nx.json').toString()); + const nxJsonInTree = readNxJson(this.host); const readJsonWithHost = (file) => ({ root: dirname(file), ...parseJson(this.host.read(file).toString()),