直到最近——我几天前才注意到这一点——我的 git pre-commit 钩子正在工作。我正在编写一个反应应用程序,并在提交之前使用 Husky、TSLint 和 Prettier 来清理和整理我的代码。现在,当我更改和提交文件时,预提交挂钩不会运行。
我的项目结构如下所示:
- project
- .git/
- react/ <- the frontend
- node_modules/
- src/
- package.json
- (other files)
- nodejs/ <- the server
- node_modules/
- src/
- package.json
- (other files)
- package.json
- (other files)
如果我手动执行钩子,它似乎运行良好:
[/project/react] # git status
On branch fixHusky
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: MyFile.ts
[/project/react] # ../.git/hooks/pre-commit
husky > pre-commit (node v12.6.0)
↓ Stashing changes... [skipped]
→ No partially staged files found...
✔ Running linters...
[/project/react] #
但是当我真正尝试提交时,哈士奇并没有运行:
[/project/react] # git commit -m "testing husky"
[fixHusky cf17a6b] testing husky
1 file changed, 1 insertion(+), 1 deletion(-)
[/project/react] #
知道为什么它没有运行吗?