Skip to content

Commit

Permalink
fix(@angular/cli): allow -a=value arguments
Browse files Browse the repository at this point in the history
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 #12308
  • Loading branch information
hansl committed Sep 27, 2018
1 parent 78a6fab commit 4daa299
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/angular/cli/models/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ export function parseArguments(args: string[], options: Option[] | null): Argume
// Argument is of form -abcdef. Starts at 1 because we skip the `-`.
for (let i = 1; i < arg.length; i++) {
const flag = arg[i];
// If the next character is an '=', treat it as a long flag.
if (arg[i + 1] == '=') {
const f = '--' + flag + arg.slice(i + 1);
_assignOption(f, args, options, parsedOptions, positionals, leftovers, ignored, errors);
break;
}
// Treat the last flag as `--a` (as if full flag but just one letter). We do this in
// the loop because it saves us a check to see if the arg is just `-`.
if (i == arg.length - 1) {
Expand Down
2 changes: 2 additions & 0 deletions packages/angular/cli/models/parser_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ describe('parseArguments', () => {
'--noHelloBool': { helloBool: false },
'--noBool': { bool: false },
'-b': { bool: true },
'-b=true': { bool: true },
'-sb': { bool: true, str: '' },
'-s=b': { str: 'b' },
'-bs': { bool: true, str: '' },
'--t1=true': { t1: true },
'--t1': { t1: true },
Expand Down

0 comments on commit 4daa299

Please sign in to comment.