From bcd43cbb3c97e31bce3000935be6d6dadfa8f424 Mon Sep 17 00:00:00 2001 From: Eric Zhang <513314660@qq.com> Date: Tue, 8 Nov 2022 22:41:21 +0800 Subject: [PATCH] fix(core): fix undefined projectName in tasks runner (#13044) Co-authored-by: eric.zhang CLOSED https://github.com/nrwl/nx/issues/13018 Fixes https://github.com/nrwl/nx/issues/13018 --- packages/nx/src/tasks-runner/utils.spec.ts | 11 ++++++++--- packages/nx/src/tasks-runner/utils.ts | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/nx/src/tasks-runner/utils.spec.ts b/packages/nx/src/tasks-runner/utils.spec.ts index 592c27be71478..a91908826632a 100644 --- a/packages/nx/src/tasks-runner/utils.spec.ts +++ b/packages/nx/src/tasks-runner/utils.spec.ts @@ -40,15 +40,20 @@ describe('utils', () => { ) ).toEqual([]); }); - it('should interpolate {workspaceRoot} and {projectRoot}', () => { + + it('should interpolate {workspaceRoot}, {projectRoot} and {projectName}', () => { expect( getOutputsForTargetAndConfiguration( task, getNode({ - outputs: ['{workspaceRoot}/one', '{projectRoot}/two'], + outputs: [ + '{workspaceRoot}/one', + '{projectRoot}/two', + '{projectName}/three', + ], }) ) - ).toEqual(['one', 'myapp/two']); + ).toEqual(['one', 'myapp/two', 'myapp/three']); }); it('should interpolate {projectRoot} when it is not in front', () => { diff --git a/packages/nx/src/tasks-runner/utils.ts b/packages/nx/src/tasks-runner/utils.ts index dbaa6014f975d..5784be714e070 100644 --- a/packages/nx/src/tasks-runner/utils.ts +++ b/packages/nx/src/tasks-runner/utils.ts @@ -157,8 +157,8 @@ export function getOutputsForTargetAndConfiguration( .map((output: string) => { return interpolate(output, { projectRoot: node.data.root, - projectName: node.data.name, - project: { ...node.data, name: node.data.name }, // this is legacy + projectName: node.name, + project: { ...node.data, name: node.name }, // this is legacy options, }); })