Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# `git worktree add` never runs `prepare`, so a worktree arrives with neither
# .husky/_ nor node_modules and the source below kills the commit before any
# gate can run. Run what this checkout can run, and never block on what it
# cannot: a checkout without dependencies has no gates to fail.
[ -d node_modules ] || exit 0
_root=$(dirname -- "$0")
[ -f "$_root/_/husky.sh" ] && . "$_root/_/husky.sh"

pnpm exec commitlint --edit "${1}"
8 changes: 7 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# `git worktree add` never runs `prepare`, so a worktree arrives with neither
# .husky/_ nor node_modules and the source below kills the commit before any
# gate can run. Run what this checkout can run, and never block on what it
# cannot: a checkout without dependencies has no gates to fail.
[ -d node_modules ] || exit 0
_root=$(dirname -- "$0")
[ -f "$_root/_/husky.sh" ] && . "$_root/_/husky.sh"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Failed lint allows commits

If node_modules exists but .husky/_/husky.sh does not, pre-commit now runs without stopping on a failed command. This can happen in a worktree with linked dependencies or dependencies installed without prepare. If pnpm run lint fails but the build and tests pass, the hook returns success and allows the commit. Enable set -e after the optional shim or check each command's result explicitly.

Suggested change
[ -f "$_root/_/husky.sh" ] && . "$_root/_/husky.sh"
[ -f "$_root/_/husky.sh" ] && . "$_root/_/husky.sh"
set -e


pnpm run lint
pnpm run build:check
Expand Down
Loading