(command: string, envVars = {})
| 27 | } |
| 28 | |
| 29 | const runCommand = (command: string, envVars = {}) => { |
| 30 | return new Promise((resolve, reject) => { |
| 31 | const [cmd, ...args] = command.split(' ') |
| 32 | const proc = spawn(cmd, args, { |
| 33 | env: { ...process.env, ...envVars }, |
| 34 | stdio: 'inherit', |
| 35 | }) |
| 36 | |
| 37 | proc.on('close', (code) => { |
| 38 | if (code !== 0) { |
| 39 | console.error(`Command failed with exit code ${code}`) |
| 40 | reject() |
| 41 | return |
| 42 | } |
| 43 | resolve(0) |
| 44 | }) |
| 45 | }) |
| 46 | } |
| 47 | |
| 48 | cli.command('').action(() => { |
| 49 | return cli.outputHelp() |