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

"prepare": "husky" 每次下载依赖的时候会覆盖钩子文件 #1462

Open
orochitian opened this issue Jun 28, 2024 · 4 comments
Open

Comments

@orochitian
Copy link

目前使用的版本是:9.0.11
由于package.json中配置了"prepare": "husky",
团队其他成员从仓库中拉取代码后,执行npm install后会自动重新创建.husky目录,包括里面的文件都会被覆盖。
这就意味着,如果我在.husky/pre-commit 中定义了自己的东西,那么别人在安装依赖的时候,就被把这些自定义的内容覆盖掉。

@squidjam
Copy link

squidjam commented Jul 3, 2024

I noticed this too, I wonder if there should be something that makes the behavior conditional.
If the file exists, don't overwrite it would be the best solution imo.

@hasan-aa
Copy link

Actually this is the behavior I want to have. So that I can enforce linting rules to the team automatically. But it doesn't happen using yarn v4.1.1.

The prepare script doesn't run at all unless called manually like yarn prepare.

@typicode
Copy link
Owner

Yarn is a special case, check docs

@squidjam
Copy link

squidjam commented Aug 9, 2024

This does not sort out the situation with npm, though. Right?
For future readers of this issue, "check docs" === a link to his blog at the bottom of the docs, so here's the link to save you all the trouble: https://blog.typicode.com/posts/husky-git-hooks-autoinstall/

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

4 participants