MCPcopy Index your code
hub / github.com/nodejs/node / configCompl

Function configCompl

deps/npm/lib/commands/completion.js:254–273  ·  view source on GitHub ↗
(opts, cmd, subCmd, npm)

Source from the content-addressed store, hash-verified

252// the current word has a dash.
253// Return the config names with the same number of dashes as the current word has.
254const configCompl = (opts, cmd, subCmd, npm) => {
255 const word = opts.word
256 const split = word.match(/^(-+)((?:no-)*)(.*)$/)
257 const dashes = split[1]
258 const no = split[2]
259
260 // Get custom definitions from the command/subcommand
261 const customDefs = getCustomDefinitions(cmd, subCmd, npm)
262 const customNames = getCustomConfigNames(customDefs)
263
264 // If there are custom definitions, return only those (new feature)
265 // Otherwise, return empty array (historical behavior - no global flag completion)
266 if (customNames.length > 0) {
267 const flags = customNames.filter(name => isFlag(name, cmd, subCmd, npm))
268 return customNames.map(c => dashes + c)
269 .concat(flags.map(f => dashes + (no || 'no-') + f))
270 }
271
272 return []
273}
274
275// expand with the valid values of various config values.
276// not yet implemented.

Callers 1

execMethod · 0.85

Calls 7

getCustomDefinitionsFunction · 0.85
getCustomConfigNamesFunction · 0.85
isFlagFunction · 0.85
concatMethod · 0.80
matchMethod · 0.65
filterMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected