(
command: string,
args: string[],
options: { cwd?: string; stdio?: 'inherit' | 'pipe' | 'ignore' } = {}
)
| 2 | |
| 3 | // Helper function to run shell commands |
| 4 | export function runCommand( |
| 5 | command: string, |
| 6 | args: string[], |
| 7 | options: { cwd?: string; stdio?: 'inherit' | 'pipe' | 'ignore' } = {} |
| 8 | ): Promise<void> { |
| 9 | return new Promise((resolve, reject) => { |
| 10 | const child = spawn(command, args, { |
| 11 | stdio: options.stdio || 'inherit', |
| 12 | cwd: options.cwd || process.cwd(), |
| 13 | }); |
| 14 | |
| 15 | child.on('close', (code) => { |
| 16 | if (code !== 0) { |
| 17 | reject( |
| 18 | new Error( |
| 19 | `Command "${command} ${args.join( |
| 20 | ' ' |
| 21 | )}" failed with exit code ${code}` |
| 22 | ) |
| 23 | ); |
| 24 | } else { |
| 25 | resolve(); |
| 26 | } |
| 27 | }); |
| 28 | |
| 29 | child.on('error', (error) => { |
| 30 | reject(error); |
| 31 | }); |
| 32 | }); |
| 33 | } |
no outgoing calls
no test coverage detected