(command, args = [], options = {})
| 2 | import process from "node:process"; |
| 3 | |
| 4 | export function runCommand(command, args = [], options = {}) { |
| 5 | const result = spawnSync(command, args, { |
| 6 | cwd: options.cwd, |
| 7 | env: options.env, |
| 8 | encoding: "utf8", |
| 9 | input: options.input, |
| 10 | maxBuffer: options.maxBuffer, |
| 11 | stdio: options.stdio ?? "pipe", |
| 12 | shell: process.platform === "win32" ? (process.env.SHELL || true) : false, |
| 13 | windowsHide: true |
| 14 | }); |
| 15 | |
| 16 | return { |
| 17 | command, |
| 18 | args, |
| 19 | status: result.status ?? 0, |
| 20 | signal: result.signal ?? null, |
| 21 | stdout: result.stdout ?? "", |
| 22 | stderr: result.stderr ?? "", |
| 23 | error: result.error ?? null |
| 24 | }; |
| 25 | } |
| 26 | |
| 27 | export function runCommandChecked(command, args = [], options = {}) { |
| 28 | const result = runCommand(command, args, options); |
no outgoing calls
no test coverage detected