MCPcopy Create free account
hub / github.com/SethGammon/Citadel / getHooksForEvent

Function getHooksForEvent

scripts/integration-test.js:83–102  ·  view source on GitHub ↗
(sandbox, event, toolName)

Source from the content-addressed store, hash-verified

81 };
82}
83
84function 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/**

Callers 2

preToolUseFunction · 0.85
postToolUseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected