(scriptName, payload, sandbox, extraEnv = {})
| 59 | |
| 60 | // ── Hook dispatch ────────────────────────────────────────────────────────────── |
| 61 | |
| 62 | function fireHookScript(scriptName, payload, sandbox, extraEnv = {}) { |
| 63 | const scriptPath = path.join(HOOKS_SRC, scriptName); |
| 64 | const input = JSON.stringify(payload); |
| 65 | const result = spawnSync('node', [scriptPath], { |
| 66 | input, |
| 67 | cwd: sandbox, |
| 68 | env: { |
| 69 | ...process.env, |
| 70 | CLAUDE_PROJECT_DIR: sandbox, |
| 71 | CLAUDE_PLUGIN_DATA: path.join(sandbox, '.claude'), |
| 72 | ...extraEnv, |
| 73 | }, |
| 74 | encoding: 'utf8', |
| 75 | timeout: 10000, |
| 76 | }); |
| 77 | return { |
| 78 | exitCode: result.status ?? -1, |
| 79 | stdout: result.stdout || '', |
| 80 | stderr: result.stderr || '', |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | function getHooksForEvent(sandbox, event, toolName) { |
no outgoing calls
no test coverage detected