Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 6f1e35a

Browse files
committed
fix: simplify Git hooks for Windows compatibility
1 parent 2f0e4e2 commit 6f1e35a

2 files changed

Lines changed: 10 additions & 34 deletions

File tree

.husky/pre-commit

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
1+
#!/usr/bin/env sh
12
branch="$(git rev-parse --abbrev-ref HEAD)"
23

34
if [ "$branch" = "main" ]; then
45
echo "You can't commit directly to main - please check out a branch."
56
exit 1
67
fi
78

8-
# Detect if running on Windows and use pnpm.cmd, otherwise use pnpm.
9-
if [ "$OS" = "Windows_NT" ]; then
10-
pnpm_cmd="pnpm.cmd"
11-
else
12-
if command -v pnpm >/dev/null 2>&1; then
13-
pnpm_cmd="pnpm"
14-
else
15-
pnpm_cmd="npx pnpm"
16-
fi
17-
fi
18-
19-
# Detect if running on Windows and use npx.cmd, otherwise use npx.
20-
if [ "$OS" = "Windows_NT" ]; then
21-
npx_cmd="npx.cmd"
22-
else
23-
npx_cmd="npx"
24-
fi
25-
26-
$npx_cmd lint-staged
27-
$pnpm_cmd lint
9+
# Use npx to run lint-staged and pnpm for lint
10+
# Git Bash on Windows automatically resolves pnpm to pnpm.cmd
11+
npx lint-staged
12+
pnpm lint

.husky/pre-push

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
1+
#!/usr/bin/env sh
12
branch="$(git rev-parse --abbrev-ref HEAD)"
23

34
if [ "$branch" = "main" ]; then
45
echo "You can't push directly to main - please check out a branch."
56
exit 1
67
fi
78

8-
# Detect if running on Windows and use pnpm.cmd, otherwise use pnpm.
9-
if [ "$OS" = "Windows_NT" ]; then
10-
pnpm_cmd="pnpm.cmd"
11-
else
12-
if command -v pnpm >/dev/null 2>&1; then
13-
pnpm_cmd="pnpm"
14-
else
15-
pnpm_cmd="npx pnpm"
16-
fi
17-
fi
18-
19-
$pnpm_cmd run check-types
9+
# Git Bash on Windows automatically resolves pnpm to pnpm.cmd
10+
pnpm run check-types
2011

2112
# Use dotenvx to securely load .env.local and run commands that depend on it
2213
if [ -f ".env.local" ]; then
2314
# Check if RUN_TESTS_ON_PUSH is set to true and run tests with dotenvx
2415
if npx dotenvx get RUN_TESTS_ON_PUSH -f .env.local 2>/dev/null | grep -q "^true$"; then
25-
npx dotenvx run -f .env.local -- $pnpm_cmd run test
16+
npx dotenvx run -f .env.local -- pnpm run test
2617
fi
2718
else
2819
# Fallback: run tests if RUN_TESTS_ON_PUSH is set in regular environment
2920
if [ "$RUN_TESTS_ON_PUSH" = "true" ]; then
30-
$pnpm_cmd run test
21+
pnpm run test
3122
fi
3223
fi
3324

0 commit comments

Comments
 (0)