diff --git a/packages/nx/src/generators/utils/project-configuration.ts b/packages/nx/src/generators/utils/project-configuration.ts index f9e173d7596c8..0efb1d3bc0f10 100644 --- a/packages/nx/src/generators/utils/project-configuration.ts +++ b/packages/nx/src/generators/utils/project-configuration.ts @@ -211,7 +211,13 @@ function readAndCombineAllProjectConfigurations(tree: Tree): { if (basename(projectFile) === 'project.json') { const json = readJson(tree, projectFile); const config = buildProjectFromProjectJson(json, projectFile); - mergeProjectConfigurationIntoRootMap(rootMap, config); + mergeProjectConfigurationIntoRootMap( + rootMap, + config, + undefined, + undefined, + true + ); } else if (basename(projectFile) === 'package.json') { const packageJson = readJson(tree, projectFile); const config = buildProjectConfigurationFromPackageJson( @@ -227,7 +233,10 @@ function readAndCombineAllProjectConfigurations(tree: Tree): { { name: config.name, root: config.root, - } + }, + undefined, + undefined, + true ); } } diff --git a/packages/nx/src/project-graph/utils/normalize-project-nodes.spec.ts b/packages/nx/src/project-graph/utils/normalize-project-nodes.spec.ts index a34162a266b6b..86d4c3f8d0157 100644 --- a/packages/nx/src/project-graph/utils/normalize-project-nodes.spec.ts +++ b/packages/nx/src/project-graph/utils/normalize-project-nodes.spec.ts @@ -80,28 +80,6 @@ describe('workspace-projects', () => { }); describe('normalizeTargets', () => { - it('should convert command property to run-commands executor', () => { - expect( - normalizeProjectTargets( - { - root: 'my/project', - targets: { - build: { - command: 'echo', - }, - }, - }, - 'build' - ).build - ).toEqual({ - executor: 'nx:run-commands', - configurations: {}, - options: { - command: 'echo', - }, - }); - }); - it('should support {projectRoot}, {workspaceRoot}, and {projectName} tokens', () => { expect( normalizeProjectTargets( diff --git a/packages/nx/src/project-graph/utils/project-configuration-utils.spec.ts b/packages/nx/src/project-graph/utils/project-configuration-utils.spec.ts index 43fe3ddcf2f76..53749382762e0 100644 --- a/packages/nx/src/project-graph/utils/project-configuration-utils.spec.ts +++ b/packages/nx/src/project-graph/utils/project-configuration-utils.spec.ts @@ -433,7 +433,10 @@ describe('project-configuration-utils', () => { "root": "libs/lib-a", "targets": { "build": { - "command": "tsc", + "executor": "nx:run-commands", + "options": { + "command": "tsc", + }, }, "echo": { "command": "echo lib-a", diff --git a/packages/nx/src/project-graph/utils/project-configuration-utils.ts b/packages/nx/src/project-graph/utils/project-configuration-utils.ts index 79e13d2320dc7..63bea10bae7e7 100644 --- a/packages/nx/src/project-graph/utils/project-configuration-utils.ts +++ b/packages/nx/src/project-graph/utils/project-configuration-utils.ts @@ -28,7 +28,10 @@ export function mergeProjectConfigurationIntoRootMap( >; }, configurationSourceMaps?: ConfigurationSourceMaps, - sourceInformation?: SourceInformation + sourceInformation?: SourceInformation, + // This function is used when reading project configuration + // in generators, where we don't want to do this. + skipCommandNormalization?: boolean ): void { if (configurationSourceMaps && !configurationSourceMaps[project.root]) { configurationSourceMaps[project.root] = {}; @@ -158,11 +161,13 @@ export function mergeProjectConfigurationIntoRootMap( updatedProjectConfiguration.targets[targetName] = mergeTargetConfigurations( - resolveCommandSyntacticSugar(target, project.root), + skipCommandNormalization + ? target + : resolveCommandSyntacticSugar(target, project.root), matchingProject.targets?.[targetName], sourceMap, sourceInformation, - `targets.${target}` + `targets.${targetName}` ); } }