| 312 | // complete against the npm commands |
| 313 | // if they all resolve to the same thing, just return the thing it already is |
| 314 | const 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 | |
| 329 | module.exports = Completion |