MCPcopy Create free account
hub / github.com/nodejs/node / cmdCompl

Function cmdCompl

deps/npm/lib/commands/completion.js:314–327  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

312// complete against the npm commands
313// if they all resolve to the same thing, just return the thing it already is
314const cmdCompl = (opts) => {
315 const allCommands = commands.concat(Object.keys(aliases))
316 const matches = allCommands.filter(c => c.startsWith(opts.partialWord))
317 if (!matches.length) {
318 return matches
319 }
320
321 const derefs = new Set([...matches.map(c => deref(c))])
322 if (derefs.size === 1) {
323 return [...derefs]
324 }
325
326 return allCommands
327}
328
329module.exports = Completion

Callers 1

execMethod · 0.85

Calls 5

derefFunction · 0.85
concatMethod · 0.80
keysMethod · 0.65
filterMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected