Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 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,15 @@ function parseOptions(args: string[]): Options {
}
}

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

return {
positionals,
builderOptions,
Expand Down
9 changes: 9 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,15 @@ function parseOptions(args: string[]): Options {
}
}

for (const key of Object.keys(CLI_OPTION_DEFINITIONS)) {
const value = values[key];
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