fix(hooks): add defensive null check for matcher.hooks to prevent Windows crash (#441)

This commit is contained in:
YeonGyu-Kim
2026-02-07 13:12:18 +09:00
parent 306da83431
commit 2e0f6bcdf8
7 changed files with 39 additions and 34 deletions
+5 -4
View File
@@ -74,11 +74,12 @@ export async function executePreToolUseHooks(
let firstHookName: string | undefined
const inputLines = buildInputLines(ctx.toolInput)
for (const matcher of matchers) {
for (const hook of matcher.hooks) {
if (hook.type !== "command") continue
for (const matcher of matchers) {
if (!matcher.hooks || matcher.hooks.length === 0) continue
for (const hook of matcher.hooks) {
if (hook.type !== "command") continue
if (isHookCommandDisabled("PreToolUse", hook.command, extendedConfig ?? null)) {
if (isHookCommandDisabled("PreToolUse", hook.command, extendedConfig ?? null)) {
log("PreToolUse hook command skipped (disabled by config)", { command: hook.command, toolName: ctx.toolName })
continue
}