Skip to content
Closed
8 changes: 8 additions & 0 deletions packages/angular_devkit/architect/bin/architect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ function parseOptions(args: string[]): Options {
}
}

for (const [key, value] of Object.entries(values)) {
if (value === 'true') {
values[key] = true;
} else if (value === 'false') {
values[key] = false;
}
}

return {
positionals,
builderOptions,
Expand Down
8 changes: 8 additions & 0 deletions packages/angular_devkit/schematics_cli/bin/schematics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,14 @@ function parseOptions(args: string[]): Options {
}
}

for (const [key, value] of Object.entries(values)) {
Comment thread
alan-agius4 marked this conversation as resolved.
Outdated
if (value === 'true') {
values[key] = true;
} else if (value === 'false') {
values[key] = false;
}
}

return {
_: positionals,
schematicOptions,
Expand Down
27 changes: 27 additions & 0 deletions packages/angular_devkit/schematics_cli/test/schematics_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@ describe('schematics-cli binary', () => {
expect(res).toEqual(0);
});

it('handles boolean CLI options with explicit inline false values', async () => {
const args = ['blank', 'foo', '--dry-run', '--debug=false'];
const res = await main({ args, stdout, stderr });
const output = stripVTControlCharacters(stdout.read()?.toString() || '');
expect(output).not.toMatch(/Debug mode enabled/);
expect(output).toMatch(/Dry run enabled\./);
expect(res).toEqual(0);
});

it('does not display help when --help=false is passed', async () => {
const args = ['blank', 'foo', '--dry-run', '--help=false'];
const res = await main({ args, stdout, stderr });
const output = stripVTControlCharacters(stdout.read()?.toString() || '');
expect(output).not.toMatch(/schematics \[collection-name:\]schematic-name/);
expect(output).toMatch(/Dry run enabled\./);
expect(res).toEqual(0);
});

it('does not list schematics when --list-schematics=false is passed', async () => {
const args = ['blank', 'foo', '--dry-run', '--list-schematics=false'];
const res = await main({ args, stdout, stderr });
const output = stripVTControlCharacters(stdout.read()?.toString() || '');
expect(output).not.toMatch(/blank/);
expect(output).toMatch(/Dry run enabled\./);
expect(res).toEqual(0);
});

it('error when no name is provided', async () => {
const args = ['blank'];
const res = await main({ args, stdout, stderr });
Expand Down
Loading