Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lancemach opened this issue Mar 1, 2024 · 2 comments
Open

Comments

@lancemach
Copy link

"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
Copy link
Owner

typicode commented Mar 1, 2024

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants