| 33 | } |
| 34 | |
| 35 | function runShell(command, cwd) { |
| 36 | const startedAt = new Date().toISOString(); |
| 37 | const result = spawnSync(command, { |
| 38 | cwd, |
| 39 | shell: true, |
| 40 | encoding: 'utf8', |
| 41 | stdio: ['ignore', 'pipe', 'pipe'], |
| 42 | }); |
| 43 | return { |
| 44 | command, |
| 45 | exitCode: result.status === null ? 1 : result.status, |
| 46 | stdout: String(result.stdout || '').slice(-4000), |
| 47 | stderr: String(result.stderr || '').slice(-4000), |
| 48 | startedAt, |
| 49 | completedAt: new Date().toISOString(), |
| 50 | }; |
| 51 | } |
| 52 | |
| 53 | function main() { |
| 54 | if (hasFlag('--help') || hasFlag('-h')) { |