(word, cmd, subCmd, npm)
| 278 | |
| 279 | // check if the thing is a flag or not. |
| 280 | const isFlag = (word, cmd, subCmd, npm) => { |
| 281 | // shorthands never take args. |
| 282 | const split = word.match(/^(-*)((?:no-)+)?(.*)$/) |
| 283 | const no = split[2] |
| 284 | const conf = split[3] |
| 285 | |
| 286 | // Check custom definitions first |
| 287 | const customDefs = getCustomDefinitions(cmd, subCmd, npm) |
| 288 | |
| 289 | // Check if conf is in custom definitions or is an alias |
| 290 | let customDef = customDefs.find(d => d.key === conf) |
| 291 | if (!customDef) { |
| 292 | // Check if conf is an alias for any of the custom definitions |
| 293 | for (const def of customDefs) { |
| 294 | if (def.alias && Array.isArray(def.alias) && def.alias.includes(conf)) { |
| 295 | customDef = def |
| 296 | break |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | if (customDef) { |
| 302 | const { type } = customDef |
| 303 | return no || |
| 304 | type === Boolean || |
| 305 | (Array.isArray(type) && type.includes(Boolean)) |
| 306 | } |
| 307 | |
| 308 | // No custom definitions found, should not reach here in normal flow since configCompl returns empty array when no custom defs exist |
| 309 | return false |
| 310 | } |
| 311 | |
| 312 | // complete against the npm commands |
| 313 | // if they all resolve to the same thing, just return the thing it already is |
no test coverage detected