| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 65c105b commit 7085a6e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -568,6 +568,15 @@ function parseOptions(args: string[]): Options { | |||
| 568 | 568 | } | |
| 569 | 569 | } | |
| 570 | 570 | ||
| 571 | + for (const key of Object.keys(CLI_OPTION_DEFINITIONS)) { | ||
| 572 | + const value = values[key]; | ||
| 573 | + if (value === 'true') { | ||
| 574 | + values[key] = true; | ||
| 575 | + } else if (value === 'false') { | ||
| 576 | + values[key] = false; | ||
| 577 | + } | ||
| 578 | + } | ||
| 579 | + | ||
| 571 | 580 | return { | |
| 572 | 581 | _: positionals, | |
| 573 | 582 | schematicOptions, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,6 +59,33 @@ describe('schematics-cli binary', () => { | |||
| 59 | 59 | expect(res).toEqual(0); | |
| 60 | 60 | }); | |
| 61 | 61 | ||
| 62 | + it('handles boolean CLI options with explicit inline false values', async () => { | ||
| 63 | + const args = ['blank', 'foo', '--dry-run', '--debug=false']; | ||
| 64 | + const res = await main({ args, stdout, stderr }); | ||
| 65 | + const output = stripVTControlCharacters(stdout.read()?.toString() || ''); | ||
| 66 | + expect(output).not.toMatch(/Debug mode enabled/); | ||
| 67 | + expect(output).toMatch(/Dry run enabled\./); | ||
| 68 | + expect(res).toEqual(0); | ||
| 69 | + }); | ||
| 70 | + | ||
| 71 | + it('does not display help when --help=false is passed', async () => { | ||
| 72 | + const args = ['blank', 'foo', '--dry-run', '--help=false']; | ||
| 73 | + const res = await main({ args, stdout, stderr }); | ||
| 74 | + const output = stripVTControlCharacters(stdout.read()?.toString() || ''); | ||
| 75 | + expect(output).not.toMatch(/schematics \[collection-name:\]schematic-name/); | ||
| 76 | + expect(output).toMatch(/Dry run enabled\./); | ||
| 77 | + expect(res).toEqual(0); | ||
| 78 | + }); | ||
| 79 | + | ||
| 80 | + it('does not list schematics when --list-schematics=false is passed', async () => { | ||
| 81 | + const args = ['blank', 'foo', '--dry-run', '--list-schematics=false']; | ||
| 82 | + const res = await main({ args, stdout, stderr }); | ||
| 83 | + const output = stripVTControlCharacters(stdout.read()?.toString() || ''); | ||
| 84 | + expect(output).not.toMatch(/blank/); | ||
| 85 | + expect(output).toMatch(/Dry run enabled\./); | ||
| 86 | + expect(res).toEqual(0); | ||
| 87 | + }); | ||
| 88 | + | ||
| 62 | 89 | it('error when no name is provided', async () => { | |
| 63 | 90 | const args = ['blank']; | |
| 64 | 91 | const res = await main({ args, stdout, stderr }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments