diff options
author | Gar <gar+gh@danger.computer> | 2022-03-24 17:18:56 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-03-28 23:21:36 +0300 |
commit | d8dcc02cfd354c1314c45d6530ec926cd138210c (patch) | |
tree | ba3721d4c4f153fe005bf9e08d450d9e2473a9a4 /lib/commands | |
parent | a64acc0bf01e4bc68b26ead5b2d5c6db47ef16c2 (diff) |
fix: consolidate command alias code
Diffstat (limited to 'lib/commands')
-rw-r--r-- | lib/commands/completion.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/commands/completion.js b/lib/commands/completion.js index 0317753a1..22f91b0ae 100644 --- a/lib/commands/completion.js +++ b/lib/commands/completion.js @@ -30,7 +30,6 @@ // const { definitions, shorthands } = require('../utils/config/index.js') -const deref = require('../utils/deref-command.js') const { aliases, cmdList, plumbing } = require('../utils/cmd-list.js') const aliasNames = Object.keys(aliases) const fullList = cmdList.concat(aliasNames).filter(c => !plumbing.includes(c)) @@ -152,7 +151,7 @@ class Completion extends BaseCommand { // check if there's a command already. const cmd = parsed.argv.remain[1] if (!cmd) { - return this.wrap(opts, cmdCompl(opts)) + return this.wrap(opts, cmdCompl(opts, this.npm)) } Object.keys(parsed).forEach(k => this.npm.config.set(k, parsed[k])) @@ -269,13 +268,13 @@ const isFlag = word => { // complete against the npm commands // if they all resolve to the same thing, just return the thing it already is -const cmdCompl = opts => { +const cmdCompl = (opts, npm) => { const matches = fullList.filter(c => c.startsWith(opts.partialWord)) if (!matches.length) { return matches } - const derefs = new Set([...matches.map(c => deref(c))]) + const derefs = new Set([...matches.map(c => npm.deref(c))]) if (derefs.size === 1) { return [...derefs] } |