Skip to content

Commit c3e2ab7

Browse files
committed
fix(@angular/cli): allow -a=value arguments
If a flag is followed by an equal sign, just treat it as a long name. So the example above would translate to --a=value, while -abc=123 would be "-a -b -c=123". Fixes angular#12308
1 parent 930dae7 commit c3e2ab7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/angular/cli/models/parser.ts

+6
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ export function parseArguments(args: string[], options: Option[] | null): Argume
281281
// Argument is of form -abcdef. Starts at 1 because we skip the `-`.
282282
for (let i = 1; i < arg.length; i++) {
283283
const flag = arg[i];
284+
// If the next character is an '=', treat it as a long flag.
285+
if (arg[i + 1] == '=') {
286+
const f = '--' + flag + arg.slice(i + 1);
287+
_assignOption(f, args, options, parsedOptions, positionals, leftovers, ignored, errors);
288+
break;
289+
}
284290
// Treat the last flag as `--a` (as if full flag but just one letter). We do this in
285291
// the loop because it saves us a check to see if the arg is just `-`.
286292
if (i == arg.length - 1) {

packages/angular/cli/models/parser_spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ describe('parseArguments', () => {
8080
'--noHelloBool': { helloBool: false },
8181
'--noBool': { bool: false },
8282
'-b': { bool: true },
83+
'-b=true': { bool: true },
8384
'-sb': { bool: true, str: '' },
85+
'-s=b': { str: 'b' },
8486
'-bs': { bool: true, str: '' },
8587
'--t1=true': { t1: true },
8688
'--t1': { t1: true },

0 commit comments

Comments
 (0)