Skip to content

Commit 3f66978

Browse files
committed
fix(@angular/cli): serialize configuration as a single argv token in run_target strategies
build-target-strategy.ts, generic-target-strategy.ts, and unit-test-strategy.ts all pushed the configuration value as a separate argv element after '-c'. Since the ng CLI's argument parser does not consume a following token as the value of a string option when that token itself starts with a dash, a configuration value crafted to look like a flag (e.g. "--outputPath=...") is instead parsed as an independent, legitimately-declared option of the target's builder, silently overriding it. Serialize configuration as a single '--configuration=value' token, matching the format serializeOptions() already uses for every other option, which is not affected by this because the value is bound to the key within one argv element. Updated the two existing spec assertions that checked the old argv shape.
1 parent 9c282d3 commit 3f66978

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

packages/angular/cli/src/commands/mcp/tools/run-target/build-target-strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class BuildTargetStrategy implements TargetStrategy {
2929
): Promise<RunTargetOutput> {
3030
const args = ['build', input.projectName];
3131
if (input.configuration) {
32-
args.push('-c', input.configuration);
32+
args.push(`--configuration=${input.configuration}`);
3333
}
3434

3535
args.push(...serializeOptions(input.options));

packages/angular/cli/src/commands/mcp/tools/run-target/generic-target-strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class GenericTargetStrategy implements TargetStrategy {
4646
}
4747

4848
if (input.configuration) {
49-
args.push('-c', input.configuration);
49+
args.push(`--configuration=${input.configuration}`);
5050
}
5151

5252
let options = input.options;

packages/angular/cli/src/commands/mcp/tools/run-target/run-target_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('Run Target Tool', () => {
4242
mockContext.workspace.extensions['defaultProject'] = 'my-app';
4343
await runTarget({ target: 'build', configuration: 'production' }, mockContext);
4444
expect(mockHost.executeNgCommand).toHaveBeenCalledWith(
45-
['build', 'my-app', '-c', 'production'],
45+
['build', 'my-app', '--configuration=production'],
4646
{
4747
cwd: '/test',
4848
},
@@ -53,7 +53,7 @@ describe('Run Target Tool', () => {
5353
mockContext.workspace.extensions['defaultProject'] = 'my-app';
5454
await runTarget({ target: 'storybook', configuration: 'docs' }, mockContext);
5555
expect(mockHost.executeNgCommand).toHaveBeenCalledWith(
56-
['run', 'my-app:storybook', '-c', 'docs'],
56+
['run', 'my-app:storybook', '--configuration=docs'],
5757
{ cwd: '/test' },
5858
);
5959
});

packages/angular/cli/src/commands/mcp/tools/run-target/unit-test-strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class UnitTestTargetStrategy implements TargetStrategy {
2828
): Promise<RunTargetOutput> {
2929
const args = ['test', input.projectName];
3030
if (input.configuration) {
31-
args.push('-c', input.configuration);
31+
args.push(`--configuration=${input.configuration}`);
3232
}
3333

3434
const builder = input.targetDefinition?.builder;

packages/angular/cli/src/commands/mcp/tools/run-target/unit-test-strategy_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('UnitTestTargetStrategy', () => {
6565
);
6666

6767
expect(mockHost.executeNgCommand).toHaveBeenCalledWith(
68-
['test', 'my-app', '-c', 'ci', '--browsers', 'ChromeHeadless', '--watch', 'false'],
68+
['test', 'my-app', '--configuration=ci', '--browsers', 'ChromeHeadless', '--watch', 'false'],
6969
{ cwd: '/test' },
7070
);
7171
});

0 commit comments

Comments
 (0)