Skip to content

Commit fe07e4a

Browse files
committed
Fix completion for partial commands
1 parent bd52304 commit fe07e4a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/completion.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ completion.usage = 'source <(npm completion)'
55
var npm = require('./npm.js')
66
var npmconf = require('./config/core.js')
77
var configDefs = npmconf.defs
8+
const { aliases, cmdList, plumbing } = require('./config/cmd-list.js')
9+
const aliasNames = Object.keys(aliases)
10+
const fullList = cmdList.concat(aliasNames).filter(c => !plumbing.includes(c))
811
var configTypes = configDefs.types
912
var shorthands = configDefs.shorthands
1013
var nopt = require('nopt')
@@ -121,8 +124,9 @@ function completion (args, cb) {
121124
var parsed = opts.conf =
122125
nopt(configTypes, shorthands, partialWords.slice(0, -1), 0)
123126
// check if there's a command already.
124-
console.error(parsed)
127+
console.error('PARSED', parsed)
125128
var cmd = parsed.argv.remain[1]
129+
console.error('CMD', cmd)
126130
if (!cmd) return cmdCompl(opts, cb)
127131

128132
Object.keys(parsed).forEach(function (k) {
@@ -244,5 +248,5 @@ function isFlag (word) {
244248

245249
// complete against the npm commands
246250
function cmdCompl (opts, cb) {
247-
return cb(null, npm.fullList)
251+
return cb(null, fullList)
248252
}

0 commit comments

Comments
 (0)