| 90 | } |
| 91 | |
| 92 | function run(command, args, options = {}) { |
| 93 | const spawnOptions = { |
| 94 | cwd: rootDir, |
| 95 | stdio: options.encoding ? ["ignore", "pipe", "inherit"] : "inherit", |
| 96 | }; |
| 97 | if (options.encoding) { |
| 98 | spawnOptions.encoding = options.encoding; |
| 99 | } |
| 100 | const result = spawnSync(command, args, spawnOptions); |
| 101 | if (result.error) { |
| 102 | if (options.optional) { |
| 103 | return result; |
| 104 | } |
| 105 | throw result.error; |
| 106 | } |
| 107 | if (result.status !== 0 && !options.optional) { |
| 108 | process.exit(result.status ?? 1); |
| 109 | } |
| 110 | return result; |
| 111 | } |