From 4daa29955847ff284d3ad753515e21a197a63ab2 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Wed, 26 Sep 2018 15:47:33 -0400 Subject: [PATCH] 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 #12308 --- packages/angular/cli/models/parser.ts | 6 ++++++ packages/angular/cli/models/parser_spec.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/packages/angular/cli/models/parser.ts b/packages/angular/cli/models/parser.ts index 99d31f93c3dd..60344f416d57 100644 --- a/packages/angular/cli/models/parser.ts +++ b/packages/angular/cli/models/parser.ts @@ -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) { diff --git a/packages/angular/cli/models/parser_spec.ts b/packages/angular/cli/models/parser_spec.ts index 73513c235c44..972c5b6b25f4 100644 --- a/packages/angular/cli/models/parser_spec.ts +++ b/packages/angular/cli/models/parser_spec.ts @@ -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 },