(program, command, rawArgs)
| 60 | } |
| 61 | |
| 62 | function executeDynamic (program, command, rawArgs) { |
| 63 | if (!command) { |
| 64 | program.outputHelp() |
| 65 | process.exit(1) |
| 66 | return |
| 67 | } |
| 68 | |
| 69 | // construct the full command line manually including flags |
| 70 | const commandIndex = rawArgs.indexOf(command) |
| 71 | const forwardedArgs = rawArgs.slice(commandIndex + 1) |
| 72 | |
| 73 | logger.debug(`command: ${command}`) |
| 74 | logger.debug(`args: ${JSON.stringify(forwardedArgs)}`) |
| 75 | |
| 76 | const binPath = path.join(process.cwd(), 'node_modules', '.bin') |
| 77 | const newPath = `${binPath}:${process.env.PATH}` |
| 78 | const env = { ...process.env, PATH: newPath } |
| 79 | |
| 80 | const spawnOptions = { stdio: 'inherit', env } |
| 81 | let result |
| 82 | for (const [spawnCommand, spawnArgs] of dynamicAttempts(command, forwardedArgs)) { |
| 83 | result = childProcess.spawnSync(spawnCommand, spawnArgs, spawnOptions) |
| 84 | if (!result.error) break |
| 85 | } |
| 86 | |
| 87 | if (result.error) { |
| 88 | if (command === 'vlt') { |
| 89 | console.log(armorBanner()) |
| 90 | } else if (command === 'ops') { |
| 91 | console.log(armorBanner()) |
| 92 | } else if (command === 'armor') { |
| 93 | console.log(armorBanner()) |
| 94 | } else { |
| 95 | logger.info(`error: unknown command '${command}'`) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | if (result.status !== 0) { |
| 100 | process.exit(result.status) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | module.exports = executeDynamic |
no test coverage detected
searching dependent graphs…