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): workspaceRoot is not correctly inrepolated when projectRoo… #13768

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/nx/src/tasks-runner/utils.spec.ts
Expand Up @@ -97,6 +97,25 @@ describe('utils', () => {
]);
});

it('should interpolate {workspaceRoot} when {projectRoot} = . by removing the slash after it', () => {
const data = {
name: 'myapp',
type: 'app',
data: {
root: '.',
targets: {
build: {
outputs: ['{workspaceRoot}/dist'],
},
},
files: [],
},
};
expect(getOutputsForTargetAndConfiguration(task, data as any)).toEqual([
'dist',
]);
});

it('should throw when {projectRoot} is used not at the beginning and the value is .', () => {
const data = {
name: 'myapp',
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/tasks-runner/utils.ts
Expand Up @@ -197,7 +197,7 @@ export function interpolate(template: string, data: any): string {
let res = template.replace('{workspaceRoot}/', '');

if (data.projectRoot == '.') {
res = template.replace('{projectRoot}/', '');
res = res.replace('{projectRoot}/', '');
}

return res.replace(/{([\s\S]+?)}/g, (match: string) => {
Expand Down