diff --git a/src/hooks/claude-code-hooks/plugin-config.ts b/src/hooks/claude-code-hooks/plugin-config.ts index d0c4836..dc935a9 100644 --- a/src/hooks/claude-code-hooks/plugin-config.ts +++ b/src/hooks/claude-code-hooks/plugin-config.ts @@ -3,7 +3,10 @@ * Contains settings for hook command execution (zsh, etc.) */ +const isWindows = process.platform === "win32" + export const DEFAULT_CONFIG = { - forceZsh: true, + // Windows doesn't have zsh by default, so we disable forceZsh on Windows + forceZsh: !isWindows, zshPath: "/bin/zsh", } diff --git a/src/hooks/comment-checker/cli.ts b/src/hooks/comment-checker/cli.ts index fb39693..245a135 100644 --- a/src/hooks/comment-checker/cli.ts +++ b/src/hooks/comment-checker/cli.ts @@ -3,10 +3,11 @@ import { createRequire } from "module" import { dirname, join } from "path" import { existsSync } from "fs" import * as fs from "fs" +import { tmpdir } from "os" import { getCachedBinaryPath, ensureCommentCheckerBinary } from "./downloader" const DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1" -const DEBUG_FILE = "/tmp/comment-checker-debug.log" +const DEBUG_FILE = join(tmpdir(), "comment-checker-debug.log") function debugLog(...args: unknown[]) { if (DEBUG) { diff --git a/src/hooks/comment-checker/downloader.ts b/src/hooks/comment-checker/downloader.ts index 2463afe..81646a4 100644 --- a/src/hooks/comment-checker/downloader.ts +++ b/src/hooks/comment-checker/downloader.ts @@ -1,11 +1,11 @@ import { spawn } from "bun" import { existsSync, mkdirSync, chmodSync, unlinkSync, appendFileSync } from "fs" import { join } from "path" -import { homedir } from "os" +import { homedir, tmpdir } from "os" import { createRequire } from "module" const DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1" -const DEBUG_FILE = "/tmp/comment-checker-debug.log" +const DEBUG_FILE = join(tmpdir(), "comment-checker-debug.log") function debugLog(...args: unknown[]) { if (DEBUG) { diff --git a/src/hooks/comment-checker/index.ts b/src/hooks/comment-checker/index.ts index 724f274..033d4b9 100644 --- a/src/hooks/comment-checker/index.ts +++ b/src/hooks/comment-checker/index.ts @@ -3,9 +3,11 @@ import { runCommentChecker, getCommentCheckerPath, startBackgroundInit, type Hoo import * as fs from "fs" import { existsSync } from "fs" +import { tmpdir } from "os" +import { join } from "path" const DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1" -const DEBUG_FILE = "/tmp/comment-checker-debug.log" +const DEBUG_FILE = join(tmpdir(), "comment-checker-debug.log") function debugLog(...args: unknown[]) { if (DEBUG) { diff --git a/src/shared/command-executor.ts b/src/shared/command-executor.ts index 060eace..b95c83a 100644 --- a/src/shared/command-executor.ts +++ b/src/shared/command-executor.ts @@ -2,9 +2,14 @@ import { spawn } from "child_process" import { exec } from "child_process" import { promisify } from "util" import { existsSync } from "fs" +import { homedir } from "os" const DEFAULT_ZSH_PATHS = ["/bin/zsh", "/usr/bin/zsh", "/usr/local/bin/zsh"] +function getHomeDir(): string { + return process.env.HOME || process.env.USERPROFILE || homedir() +} + function findZshPath(customZshPath?: string): string | null { if (customZshPath && existsSync(customZshPath)) { return customZshPath @@ -39,7 +44,7 @@ export async function executeHookCommand( cwd: string, options?: ExecuteHookOptions ): Promise { - const home = process.env.HOME ?? "" + const home = getHomeDir() let expandedCommand = command .replace(/^~(?=\/|$)/g, home)