(command: string)
| 4 | import { cliPrint } from '../src'; |
| 5 | |
| 6 | export const runCommand = (command: string) => { |
| 7 | logger.log(`Running command:\n${command}`); |
| 8 | const result = spawnSync(command, { |
| 9 | shell: true, |
| 10 | }); |
| 11 | |
| 12 | if (result.status !== 0 || result.error) { |
| 13 | throw new Error(`Command failed with non-zero status code. Output:\n${result.stdout.toString()}`); |
| 14 | } |
| 15 | |
| 16 | const stderr = result.stderr.toString(); |
| 17 | if (stderr) { |
| 18 | cliPrint.warning(`Stderr output:\n${stderr}`); |
| 19 | } |
| 20 | |
| 21 | const stdout = result.stdout.toString(); |
| 22 | if (stdout) { |
| 23 | consoleLog(`Stdout output:\n${stdout}`); |
| 24 | } |
| 25 | return stdout; |
| 26 | }; |
| 27 | |
| 28 | export const runCommandInBackground = (command: string) => { |
| 29 | logger.log(`Running background command:\n${command}`); |
no test coverage detected