husky
husky copied to clipboard
[husky install]Project initialization leads to functional failure issues
"husky": "^9.0.11",
"scripts": {
"prepare": "husky install"
},
First I have husky set up in my project and everything is working. And add it to git version control. I then cloned the project on another machine and ran pnpm install, overwriting the pre-commit and commit-msg files because of husky initialization. Because I have custom code in these two files. How should I deal with this problem, thank you!
# commit-msg
# . "${0%/*}/h"
. "$(dirname -- "$0")/husky.sh"
npx --no-install commitlint --edit
# pre-commit
#!/usr/bin/env sh
# . "${0%/*}/h"
. "$(dirname -- "$0")/husky.sh"
pnpm lint && pnpm format && pnpm style:lint
husky init
should only be run once on a project
when cloning the project on another machine, you just need to run pnpm install
to have hooks working.
husky init
should only be run once on a project when cloning the project on another machine, you just need to runpnpm install
to have hooks working.
Could you please describe this in detail. I meet the same issue: when clone the repository, the prepare
script will reset all hooks in my project. Here is my config:
// package.json
"scripts": {
"prepare": "husky"
}
我也遇到了相同的问题,每当prepare执行husky的时候,.husky文件夹都会重新下载一遍,这就导致我们本地配置好的pre-commit文件被覆盖了。因为是团队开发,我希望一些操作是自动的。当团队其他成员拉取代码并安装依赖后,它应该自动执行。而不是每个人都需要再执行一遍某个命令,或者再配置一次pre-commit文件。