MCPcopy Create free account
hub / github.com/WJX20/claude-code / hasHookForEvent

Function hasHookForEvent

src/utils/hooks.ts:1664–1675  ·  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

1662 * See hasInstructionsLoadedHook / hasWorktreeCreateHook for the same pattern.
1663 */
1664function hasHookForEvent(
1665 hookEvent: HookEvent,
1666 appState: AppState | undefined,
1667 sessionId: string,
1668): boolean {
1669 const snap = getHooksConfigFromSnapshot()?.[hookEvent]
1670 if (snap && snap.length > 0) return true
1671 const reg = getRegisteredHooks()?.[hookEvent]
1672 if (reg && reg.length > 0) return true
1673 if (appState?.sessionHooks.get(sessionId)?.hooks[hookEvent]) return true
1674 return false
1675}
1676
1677/**
1678 * 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.45

Tested by

no test coverage detected