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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.