Skip to content
Discussion options

You must be logged in to vote

Hi @janeklb

In Husky v9, hooks are plain POSIX shell scripts — no shebang or sourcing needed.

What changed in v9

The .husky/_ directory is a Husky internal directory. You don't need to source it. Hook scripts are simple shell commands:

echo "Step 1"
npx lint-staged

echo "Step 2"
npx ...

No shebang required

In v9, Husky executes hooks directly. The shebang and the sourcing line from v8 are no longer needed.

If you need Bash features

If your hook requires Bash-specific syntax, use this pattern:

bash << EOF
# Your bash script here
if [ "$SOME_VAR" = "value" ]; then
  echo "Conditional step"
fi
EOF

Testing

After editing, test with:

git commit --allow-empty -m "test hook"

The exit 1 trick sti…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by janeklb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants