Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): ensure output paths returned are unique #18207

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions packages/nx/src/tasks-runner/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
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
Expand Down