typicode / husky

Git hooks made easy 🐶 woof!
https://typicode.github.io/husky
MIT License
31.68k stars 996 forks source link

[husky install]Project initialization leads to functional failure issues #1398

Open lancemach opened 2 months ago

lancemach commented 2 months ago

"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
typicode commented 2 months ago

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.

zayne-wang commented 2 months ago

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.

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"
}