MCPcopy
hub / github.com/claude-code-best/claude-code / hasHookForEvent

Function hasHookForEvent

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

1716 * See hasInstructionsLoadedHook / hasWorktreeCreateHook for the same pattern.
1717 */
1718function hasHookForEvent(
1719 hookEvent: HookEvent,
1720 appState: AppState | undefined,
1721 sessionId: string,
1722): boolean {
1723 const snap = getHooksConfigFromSnapshot()?.[hookEvent]
1724 if (snap && snap.length > 0) return true
1725 const reg = getRegisteredHooks()?.[hookEvent]
1726 if (reg && reg.length > 0) return true
1727 if (appState?.sessionHooks.get(sessionId)?.hooks[hookEvent]) return true
1728 return false
1729}
1730
1731/**
1732 * 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