Skip to content

Commit be90045

Browse files
committed
fix: Improve Windows compatibility for paths and shell config
- Use os.tmpdir() instead of hardcoded /tmp for cross-platform temp files - Use os.homedir() with USERPROFILE fallback for Windows home directory - Disable forceZsh on Windows (zsh not available by default) 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent a10ee64 commit be90045

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

src/hooks/claude-code-hooks/plugin-config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
* Contains settings for hook command execution (zsh, etc.)
44
*/
55

6+
const isWindows = process.platform === "win32"
7+
68
export const DEFAULT_CONFIG = {
7-
forceZsh: true,
9+
// Windows doesn't have zsh by default, so we disable forceZsh on Windows
10+
forceZsh: !isWindows,
811
zshPath: "/bin/zsh",
912
}

src/hooks/comment-checker/cli.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { createRequire } from "module"
33
import { dirname, join } from "path"
44
import { existsSync } from "fs"
55
import * as fs from "fs"
6+
import { tmpdir } from "os"
67
import { getCachedBinaryPath, ensureCommentCheckerBinary } from "./downloader"
78

89
const DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1"
9-
const DEBUG_FILE = "/tmp/comment-checker-debug.log"
10+
const DEBUG_FILE = join(tmpdir(), "comment-checker-debug.log")
1011

1112
function debugLog(...args: unknown[]) {
1213
if (DEBUG) {

src/hooks/comment-checker/downloader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { spawn } from "bun"
22
import { existsSync, mkdirSync, chmodSync, unlinkSync, appendFileSync } from "fs"
33
import { join } from "path"
4-
import { homedir } from "os"
4+
import { homedir, tmpdir } from "os"
55
import { createRequire } from "module"
66

77
const DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1"
8-
const DEBUG_FILE = "/tmp/comment-checker-debug.log"
8+
const DEBUG_FILE = join(tmpdir(), "comment-checker-debug.log")
99

1010
function debugLog(...args: unknown[]) {
1111
if (DEBUG) {

src/hooks/comment-checker/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { runCommentChecker, getCommentCheckerPath, startBackgroundInit, type Hoo
33

44
import * as fs from "fs"
55
import { existsSync } from "fs"
6+
import { tmpdir } from "os"
7+
import { join } from "path"
68

79
const DEBUG = process.env.COMMENT_CHECKER_DEBUG === "1"
8-
const DEBUG_FILE = "/tmp/comment-checker-debug.log"
10+
const DEBUG_FILE = join(tmpdir(), "comment-checker-debug.log")
911

1012
function debugLog(...args: unknown[]) {
1113
if (DEBUG) {

src/shared/command-executor.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ import { spawn } from "child_process"
22
import { exec } from "child_process"
33
import { promisify } from "util"
44
import { existsSync } from "fs"
5+
import { homedir } from "os"
56

67
const DEFAULT_ZSH_PATHS = ["/bin/zsh", "/usr/bin/zsh", "/usr/local/bin/zsh"]
78

9+
function getHomeDir(): string {
10+
return process.env.HOME || process.env.USERPROFILE || homedir()
11+
}
12+
813
function findZshPath(customZshPath?: string): string | null {
914
if (customZshPath && existsSync(customZshPath)) {
1015
return customZshPath
@@ -39,7 +44,7 @@ export async function executeHookCommand(
3944
cwd: string,
4045
options?: ExecuteHookOptions
4146
): Promise<CommandResult> {
42-
const home = process.env.HOME ?? ""
47+
const home = getHomeDir()
4348

4449
let expandedCommand = command
4550
.replace(/^~(?=\/|$)/g, home)

0 commit comments

Comments
 (0)