diff options
Diffstat (limited to 'lib/commands/completion.js')
-rw-r--r-- | lib/commands/completion.js | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/commands/completion.js b/lib/commands/completion.js index bce6c3619..504528c90 100644 --- a/lib/commands/completion.js +++ b/lib/commands/completion.js @@ -166,7 +166,7 @@ class Completion extends BaseCommand { // at this point, if words[1] is some kind of npm command, // then complete on it. // otherwise, do nothing - const impl = this.npm.cmd(cmd) + const impl = await this.npm.cmd(cmd) if (impl.completion) { const comps = await impl.completion(opts) return this.wrap(opts, comps) @@ -180,12 +180,10 @@ class Completion extends BaseCommand { // Ie, returning ['a', 'b c', ['d', 'e']] would allow it to expand // to: 'a', 'b c', or 'd' 'e' wrap (opts, compls) { - if (!Array.isArray(compls)) { - compls = compls ? [compls] : [] - } - - compls = compls.map(c => - Array.isArray(c) ? c.map(escape).join(' ') : escape(c)) + // TODO this was dead code, leaving it in case we find some command we + // forgot that requires this. if so *that command should fix its + // completions* + // compls = compls.map(w => !/\s+/.test(w) ? w : '\'' + w + '\'') if (opts.partialWord) { compls = compls.filter(c => c.startsWith(opts.partialWord)) @@ -246,9 +244,6 @@ const dumpScript = async () => { const unescape = w => w.charAt(0) === '\'' ? w.replace(/^'|'$/g, '') : w.replace(/\\ /g, ' ') -const escape = w => !/\s+/.test(w) ? w - : '\'' + w + '\'' - // the current word has a dash. Return the config names, // with the same number of dashes as the current word has. const configCompl = opts => { |