(command: string, options: CommandOptions)
| 71 | } |
| 72 | |
| 73 | export async function runCommand(command: string, options: CommandOptions) { |
| 74 | const stringifiedOptions = JSON.stringify(options); |
| 75 | const commandSpinner = logger.debugSpinner(`Running command '${command}' with options ${stringifiedOptions}`); |
| 76 | |
| 77 | const goExec = await go(() => exec(command, options)); |
| 78 | if (!goExec.success) { |
| 79 | if (options.ignoreError) { |
| 80 | if (logger.inDebugMode()) { |
| 81 | logger.getSpinner().info(); |
| 82 | logger.warn(`Warning: ${goExec.error.message}`); |
| 83 | } |
| 84 | commandSpinner.warn(`Command '${command}' with options ${stringifiedOptions} failed`); |
| 85 | return ''; |
| 86 | } |
| 87 | |
| 88 | logger.getSpinner().info(); |
| 89 | commandSpinner.fail(`Command '${command}' with options ${stringifiedOptions} failed`); |
| 90 | throw logAndReturnError(goExec.error.toString()); |
| 91 | } |
| 92 | |
| 93 | commandSpinner.succeed(`Finished command '${command}' with options ${stringifiedOptions}`); |
| 94 | return goExec.data.stdout; |
| 95 | } |
| 96 | |
| 97 | export type CommandArg = string | [string, string] | [string, string, string]; |
| 98 |
no test coverage detected