(scriptPath: string, input: object, env?: Record<string, string>)
| 9 | const FREEZE_SCRIPT = path.join(ROOT, 'freeze', 'bin', 'check-freeze.sh'); |
| 10 | |
| 11 | function runHook(scriptPath: string, input: object, env?: Record<string, string>): { exitCode: number; output: any; raw: string } { |
| 12 | const result = spawnSync('bash', [scriptPath], { |
| 13 | input: JSON.stringify(input), |
| 14 | stdio: ['pipe', 'pipe', 'pipe'], |
| 15 | env: { ...process.env, ...env }, |
| 16 | timeout: 5000, |
| 17 | }); |
| 18 | const raw = result.stdout.toString().trim(); |
| 19 | let output: any = {}; |
| 20 | try { |
| 21 | output = JSON.parse(raw); |
| 22 | } catch {} |
| 23 | return { exitCode: result.status ?? 1, output, raw }; |
| 24 | } |
| 25 | |
| 26 | function runHookRaw(scriptPath: string, rawInput: string, env?: Record<string, string>): { exitCode: number; output: any; raw: string } { |
| 27 | const result = spawnSync('bash', [scriptPath], { |
no test coverage detected