Skip to content

Commit 930dae7

Browse files
committed
fix(@angular/cli): allow empty string arguments
1 parent 5c6c704 commit 930dae7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/angular/cli/models/parser.ts

-4
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,6 @@ export function parseArguments(args: string[], options: Option[] | null): Argume
269269
const errors: string[] = [];
270270

271271
for (let arg = args.shift(); arg !== undefined; arg = args.shift()) {
272-
if (!arg) {
273-
break;
274-
}
275-
276272
if (arg == '--') {
277273
// If we find a --, we're done.
278274
leftovers.push(...args);

packages/angular/cli/models/parser_spec.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('parseArguments', () => {
3535
const tests: { [test: string]: Partial<Arguments> | ['!!!', Partial<Arguments>, string[]] } = {
3636
'--bool': { bool: true },
3737
'--bool=1': ['!!!', {}, ['--bool=1']],
38+
'--bool ': { bool: true, p1: '' },
3839
'-- --bool=1': { '--': ['--bool=1'] },
3940
'--bool=yellow': ['!!!', {}, ['--bool=yellow']],
4041
'--bool=true': { bool: true },
@@ -68,6 +69,10 @@ describe('parseArguments', () => {
6869
'--arr=1 --arr --arr c d': { arr: ['1', '', 'c'], p1: 'd' },
6970
'--arr=1 --arr --arr c d e': { arr: ['1', '', 'c'], p1: 'd', p2: 'e' },
7071
'--str=1': { str: '1' },
72+
'--str=': { str: '' },
73+
'--str ': { str: '' },
74+
'--str ': { str: '', p1: '' },
75+
'--str ': { str: '', p1: '', p2: '', '--': [''] },
7176
'--hello-world=1': { helloWorld: '1' },
7277
'--hello-bool': { helloBool: true },
7378
'--helloBool': { helloBool: true },
@@ -119,7 +124,7 @@ describe('parseArguments', () => {
119124
Object.entries(tests).forEach(([str, expected]) => {
120125
it(`works for ${str}`, () => {
121126
try {
122-
const actual = parseArguments(str.split(/\s+/), options);
127+
const actual = parseArguments(str.split(' '), options);
123128

124129
expect(Array.isArray(expected)).toBe(false);
125130
expect(actual).toEqual(expected as Arguments);

0 commit comments

Comments
 (0)