| 40 | } |
| 41 | |
| 42 | export function shellExec(command: string, options: cp.ExecOptionsWithStringEncoding = {}, suppressOutput: boolean = false, doNotThrow: boolean = false): Promise<ExecResult> { |
| 43 | return new Promise<ExecResult>((resolve, reject) => { |
| 44 | cp.exec(command, options, (error, stdout, stderr) => { |
| 45 | if (!suppressOutput) { |
| 46 | console.log(stdout); |
| 47 | console.error(stderr); |
| 48 | } |
| 49 | ((error && !doNotThrow) ? reject : resolve)({ error, stdout, stderr }); |
| 50 | }); |
| 51 | }); |
| 52 | } |
| 53 | |
| 54 | export interface BufferExecResult { |
| 55 | stdout: Buffer; |