From dfe59908a6c38181cfe765e8829e5d88e7a82861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georg=20M=C3=BCller?= Date: Fri, 24 Mar 2017 21:57:10 +0100 Subject: [PATCH] fix(@angular/cli): correctly build completion with blueprints and options before, if both blueprints and options are present, a space was missing between them, resulting in "service--dryrun" instead of "service --dryrun" Patch v2: * use template string * fix indentation of generated bash output --- packages/@angular/cli/commands/completion.ts | 23 ++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/@angular/cli/commands/completion.ts b/packages/@angular/cli/commands/completion.ts index b755ab49ee0d..87fca2f5d138 100644 --- a/packages/@angular/cli/commands/completion.ts +++ b/packages/@angular/cli/commands/completion.ts @@ -7,7 +7,7 @@ const stringUtils = require('ember-cli-string-utils'); const Command = require('../ember-cli/lib/models/command'); const lookupCommand = require('../ember-cli/lib/cli/lookup-command'); -function extractOptions(opts: any): string { +function extractOptions(opts: any): string[] { const output: string[] = []; for (let index = 0; index < opts.length; index++) { @@ -18,10 +18,10 @@ function extractOptions(opts: any): string { } } - return output.sort().join(' '); + return output; } -function extractBlueprints(opts: any): string { +function extractBlueprints(opts: any): string[] { const output: string[] = []; for (let index = 0; index < opts.length; index++) { @@ -29,7 +29,7 @@ function extractBlueprints(opts: any): string { output.push(element.name); } - return output.sort().join(' '); + return output; } export interface CompletionCommandOptions { @@ -117,20 +117,21 @@ const CompletionCommand = Command.extend({ }); } - let opts = ''; + let opts: string[] = []; if (command.blueprints && command.blueprints[0]) { - opts += extractBlueprints(command.blueprints); + opts = opts.concat(extractBlueprints(command.blueprints)); } if (command.availableOptions && command.availableOptions[0]) { - opts += extractOptions(command.availableOptions); - caseBlock = caseBlock + ' ' + com.sort().join('|') + ') opts="' + opts + '" ;;\n'; + opts = opts.concat(extractOptions(command.availableOptions)); + const optsStr = opts.sort().join(' '); + caseBlock = `${caseBlock} + ${com.sort().join('|')}) opts="${optsStr}" ;;`; } }); - caseBlock = 'ng|help) opts="' + optsNg.sort().join(' ') + '" ;;\n' + - caseBlock + - ' *) opts="" ;;'; + caseBlock = `ng|help) opts="${optsNg.sort().join(' ')}" ;;${caseBlock} + *) opts="" ;;`; console.log(stripIndent` ###-begin-ng-completion###