我已经在我的应用程序中安装了 Husky v5,我想在提交时运行该lint-staged命令。
我遵循了入门文档,但在我的 git 配置文件中没有创建 .git/hooks/pre-commit 文件。
所以,当我提交时,钩子没有运行,提交直接通过,没有被 lint-staged 检查。
我尝试运行yarn add -D husky@next或npm i -D husky@next. 我还尝试删除 node_modules 和 npm rebuild。
.husky/预提交
#!/bin/sh
[ -z "$CI" ] && exit 0
. "$(dirname $0)/_/husky.sh"
lint-staged
Run Code Online (Sandbox Code Playgroud)
包.json
"scripts": {
"postinstall": "husky install"
},
Run Code Online (Sandbox Code Playgroud)
小智 6
husky v5 不生成钩子(不能说为什么),
所以我降级到 4.3.8 并删除了 .git/hooks(不必要):
rm -rf .git/hooks
yarn add -D husky@4.3.8
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4363 次 |
| 最近记录: |