typicode / husky

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

fix: husky will replace existing hook #1407

Closed zayne-wang closed 2 months ago

zayne-wang commented 2 months ago

fix: fix the issue #1387

typicode commented 2 months ago

Thank you for the PR. Actually files in .husky/_/ are owned by husky and shouldn't be edited. That's why they get replaced.

User hooks needs to be in .husky/. For example, if you create .husky/pre-commit it won't be replaced.

rdmark commented 4 weeks ago

@typicode Thanks for an awesome tool!

User hooks needs to be in .husky/. For example, if you create .husky/pre-commit it won't be replaced.

This does not match what I'm seeing with husky 9.0.11. I have my own .husky/pre-commit file with custom commands. When I run npx husky init this file gets overwritten with the default npm test again.

I wonder if this is a bug, or some kind of misunderstanding?

typicode commented 4 weeks ago

Thanks for the kind words :)

Some kind of misunderstanding. husky init is an automatic setup and should be run once (like npm init or git init for example).