(sandbox, event, toolName)
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | function getHooksForEvent(sandbox, event, toolName) { |
| 85 | const settingsPath = path.join(sandbox, '.claude', 'settings.json'); |
| 86 | const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); |
| 87 | const entries = (settings.hooks || {})[event] || []; |
| 88 | const matched = []; |
| 89 | |
| 90 | for (const entry of entries) { |
| 91 | if (entry.matcher) { |
| 92 | const re = new RegExp(`^(${entry.matcher})$`); |
| 93 | if (!re.test(toolName || '')) continue; |
| 94 | } |
| 95 | for (const hook of (entry.hooks || [])) { |
| 96 | if (!hook.command) continue; |
| 97 | const m = hook.command.match(/node\s+"?([^"\s]+\.js)"?/); |
| 98 | if (m) matched.push(m[1]); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return matched; |
| 103 | } |
| 104 | |
| 105 | /** |
no outgoing calls
no test coverage detected