diff --git a/packages/nx/src/tasks-runner/utils.ts b/packages/nx/src/tasks-runner/utils.ts index c0ae7d81233dc..b3282b8d17657 100644 --- a/packages/nx/src/tasks-runner/utils.ts +++ b/packages/nx/src/tasks-runner/utils.ts @@ -322,19 +322,22 @@ export function getOutputsForTargetAndConfiguration( if (targetConfiguration?.outputs) { validateOutputs(targetConfiguration.outputs); - return targetConfiguration.outputs - .map((output: string) => { - return interpolate(output, { - projectRoot: node.data.root, - projectName: node.name, - project: { ...node.data, name: node.name }, // this is legacy - options, - }); - }) - .filter( - (output) => - !!output && !output.match(/{(projectRoot|workspaceRoot|(options.*))}/) - ); + const result = new Set(); + for (const output of targetConfiguration.outputs) { + const interpolatedOutput = interpolate(output, { + projectRoot: node.data.root, + projectName: node.name, + project: { ...node.data, name: node.name }, // this is legacy + options, + }); + if ( + !!interpolatedOutput && + !interpolatedOutput.match(/{(projectRoot|workspaceRoot|(options.*))}/) + ) { + result.add(interpolatedOutput); + } + } + return Array.from(result); } // Keep backwards compatibility in case `outputs` doesn't exist