Skip to content

Commit

Permalink
fix(core): workspaceRoot is not correctly inrepolated when projectRoo… (
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Dec 12, 2022
1 parent af157ff commit dd490c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

1 comment on commit dd490c1

@vercel
Copy link

@vercel vercel bot commented on dd490c1 Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app

Please sign in to comment.