Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-11-10 19:30:39 +0300
committerGar <gar+gh@danger.computer>2021-11-11 01:35:44 +0300
commit72ca4a4e39a1d4de03d6423480aa2ee82b021060 (patch)
tree81c0f265a4eceb14f4bef0c2adbf690d2bb52e3a /lib/commands/completion.js
parentac4f9e4c55f9f97d99e2a11f0ef5dd9b900b0ef0 (diff)
fix: command completion
The fake npm object in the tests wasn't returning an async function Fixes: https://github.com/npm/cli/issues/4020 PR-URL: https://github.com/npm/cli/pull/4032 Credit: @wraithgar Close: #4032 Reviewed-by: @lukekarrys
Diffstat (limited to 'lib/commands/completion.js')
-rw-r--r--lib/commands/completion.js15
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 => {