FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(angular-devkit): correctly parse inline boolean values in CLI options by alan-agius4 · Pull Request #34201 · angular/angular-cli · GitHub

Repository navigation

9 changes: 9 additions & 0 deletions packages/angular_devkit/architect/bin/architect.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL