MCPcopy Index your code
hub / github.com/codeaashu/claude-code / hasHookForEvent

Function hasHookForEvent

src/utils/hooks.ts:1582–1593  ·  view source on GitHub ↗

* Lightweight existence check for hooks on a given event. Mirrors the sources * assembled by getHooksConfig() but stops at the first hit without building * the full merged config. * * Intentionally over-approximates: returns true if any matcher exists for the * event, even if managed-only filte

(
  hookEvent: HookEvent,
  appState: AppState | undefined,
  sessionId: string,
)

Source from the content-addressed store, hash-verified

1580 * See hasInstructionsLoadedHook / hasWorktreeCreateHook for the same pattern.
1581 */
1582function hasHookForEvent(
1583 hookEvent: HookEvent,
1584 appState: AppState | undefined,
1585 sessionId: string,
1586): boolean {
1587 const snap = getHooksConfigFromSnapshot()?.[hookEvent]
1588 if (snap && snap.length > 0) return true
1589 const reg = getRegisteredHooks()?.[hookEvent]
1590 if (reg && reg.length > 0) return true
1591 if (appState?.sessionHooks.get(sessionId)?.hooks[hookEvent]) return true
1592 return false
1593}
1594
1595/**
1596 * Get hook commands that match the given query

Callers 6

executePreToolHooksFunction · 0.85
executeStopFailureHooksFunction · 0.85
executeStopHooksFunction · 0.85

Calls 3

getRegisteredHooksFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected