(command: string, options?: ExecSyncOptions)
| 20 | }; |
| 21 | |
| 22 | export const runCommand = (command: string, options?: ExecSyncOptions) => { |
| 23 | const { hiddenCommand, hiddenOptions } = hideSecrets(command, options); |
| 24 | |
| 25 | logger.log(`Running command: '${hiddenCommand}' with options ${JSON.stringify(hiddenOptions)}`); |
| 26 | try { |
| 27 | return execSync(command, options)?.toString().trim(); |
| 28 | } catch (e) { |
| 29 | // Thrown Error object contains the entire result from child_process.spawnSync() |
| 30 | const err = e as any; |
| 31 | throw new Error( |
| 32 | [ |
| 33 | ``, |
| 34 | `Command failed with non-zero status code: ${err.status}`, |
| 35 | `Stderr: ${err.stderr?.toString().trim()}.`, |
| 36 | `Stdout: ${err.stdout?.toString().trim()}.`, |
| 37 | ].join('\n') |
| 38 | ); |
| 39 | } |
| 40 | }; |
| 41 | |
| 42 | export const unifyUrlFormat = (url: string) => (url.endsWith('/') ? url.slice(0, -1) : url); |
| 43 |
no test coverage detected