Reputation: 2341
How can I have two precommit hooks in husky? I'm looking to use commitlint along side a custom script defined in my package.json. I have installed husky and have a pre-commit script in the .husky folder. Here is what I've tried:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx commitlint --edit
npm run mycommand
I tried npx commitlint --edit && npm run mycommand
I have also tried removing the commitlint command in this file and adding a second file commit-msg
in my .husky folder with the following:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx commitlint --edit $1
When when I run these the custom command runs but commitlint does not check the message.
How can I run commitlint with my custom command?
Upvotes: 0
Views: 615
Reputation: 1
run this cmd in terminal
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}'
it will create a commit-msg file in .husky folder and then test with git commit msg
Upvotes: 0