Merge pull request #1584 from code-yeongyu/fix/441-matcher-hooks-undefined
fix(hooks): add defensive null check for matcher.hooks to prevent Windows crash (#441)
This commit is contained in:
commit
1cb8f8bee6
@ -20,7 +20,7 @@ interface RawClaudeHooksConfig {
|
|||||||
function normalizeHookMatcher(raw: RawHookMatcher): HookMatcher {
|
function normalizeHookMatcher(raw: RawHookMatcher): HookMatcher {
|
||||||
return {
|
return {
|
||||||
matcher: raw.matcher ?? raw.pattern ?? "*",
|
matcher: raw.matcher ?? raw.pattern ?? "*",
|
||||||
hooks: raw.hooks,
|
hooks: Array.isArray(raw.hooks) ? raw.hooks : [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,6 +92,7 @@ export async function executePostToolUseHooks(
|
|||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
|
|
||||||
for (const matcher of matchers) {
|
for (const matcher of matchers) {
|
||||||
|
if (!matcher.hooks || matcher.hooks.length === 0) continue
|
||||||
for (const hook of matcher.hooks) {
|
for (const hook of matcher.hooks) {
|
||||||
if (hook.type !== "command") continue
|
if (hook.type !== "command") continue
|
||||||
|
|
||||||
|
|||||||
@ -48,6 +48,7 @@ export async function executePreCompactHooks(
|
|||||||
const collectedContext: string[] = []
|
const collectedContext: string[] = []
|
||||||
|
|
||||||
for (const matcher of matchers) {
|
for (const matcher of matchers) {
|
||||||
|
if (!matcher.hooks || matcher.hooks.length === 0) continue
|
||||||
for (const hook of matcher.hooks) {
|
for (const hook of matcher.hooks) {
|
||||||
if (hook.type !== "command") continue
|
if (hook.type !== "command") continue
|
||||||
|
|
||||||
|
|||||||
@ -75,6 +75,7 @@ export async function executePreToolUseHooks(
|
|||||||
const inputLines = buildInputLines(ctx.toolInput)
|
const inputLines = buildInputLines(ctx.toolInput)
|
||||||
|
|
||||||
for (const matcher of matchers) {
|
for (const matcher of matchers) {
|
||||||
|
if (!matcher.hooks || matcher.hooks.length === 0) continue
|
||||||
for (const hook of matcher.hooks) {
|
for (const hook of matcher.hooks) {
|
||||||
if (hook.type !== "command") continue
|
if (hook.type !== "command") continue
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,7 @@ export async function executeStopHooks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const matcher of matchers) {
|
for (const matcher of matchers) {
|
||||||
|
if (!matcher.hooks || matcher.hooks.length === 0) continue
|
||||||
for (const hook of matcher.hooks) {
|
for (const hook of matcher.hooks) {
|
||||||
if (hook.type !== "command") continue
|
if (hook.type !== "command") continue
|
||||||
|
|
||||||
|
|||||||
@ -71,6 +71,7 @@ export async function executeUserPromptSubmitHooks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const matcher of matchers) {
|
for (const matcher of matchers) {
|
||||||
|
if (!matcher.hooks || matcher.hooks.length === 0) continue
|
||||||
for (const hook of matcher.hooks) {
|
for (const hook of matcher.hooks) {
|
||||||
if (hook.type !== "command") continue
|
if (hook.type !== "command") continue
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user