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(devkit): make parseTargetString more tolerant to bad graph shapes #20170

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
21 changes: 21 additions & 0 deletions packages/devkit/src/executors/parse-target-string.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ describe('parseTargetString', () => {
target: 'build',
});
});

// When running a converted executor, its possible that the context has a project name that
// isn't present within the project graph. In these cases, this function should still behave predictably.
it('should produce accurate results if the project graph doesnt contain the project', () => {
expect(
parseTargetString('foo:build', { ...mockContext, projectName: 'foo' })
).toEqual({
project: 'foo',
target: 'build',
});
expect(
parseTargetString('foo:build:production', {
...mockContext,
projectName: 'foo',
})
).toEqual({
project: 'foo',
target: 'build',
configuration: 'production',
});
});
});

describe('targetToTargetString', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/devkit/src/executors/parse-target-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export function parseTargetString(
if (
!projectGraph.nodes[maybeProject] &&
projectGraphOrCtx &&
'projectName' in projectGraphOrCtx
'projectName' in projectGraphOrCtx &&
maybeProject !== projectGraphOrCtx.projectName
) {
targetString = `${projectGraphOrCtx.projectName}:${targetString}`;
}
Expand Down