git - 预提交挂钩失败
问题描述
我正在为我的新项目使用NestJs。
我正在使用此命令添加所有文件。 git add .
当我在添加所有文件后提交时,赫斯基会阻止提交并向我显示此错误。
[文件路径]/.spec.ts' 不包含在项目中。
husky > pre-commit hook 失败(添加 --no-verify 绕过)
我隐式添加了该文件,但它仍然向我抛出该错误。
我的 tsconfig.json 文件
{
"compilerOptions": {
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"allowJs": true,
"outDir": "./dist",
"baseUrl": "./src",
"lib": ["dom", "es2018", "esnext"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
这就是我在 package.json 文件中添加 husky 命令的方式
"scripts": {
"lint": "tslint -p tsconfig.json -c tslint.json",
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"post-commit": "git push origin HEAD"
}
},
"lint-staged": {
"*.ts": [
"tslint -p tsconfig.json -c tslint.json",
"git add"
]
},
解决方案
If you are on windows OS, the hooks script which will include in your package.json should be of this form below
"husky": {
"hooks": {
"pre-push": "set CI=true&&npm test"
}
},
For other Operating System make use of below snippet
"husky": {
"hooks": {
"pre-push": "CI=true npm test"}},
More information on: https://facebook.github.io/create-react-app/docs/running-tests#on-your-own-environment
推荐阅读
- angular - Angular 6 组件同时作为一个对话框(angular material dialogRef)和自身。可能吗?
- python - 使用 spaCy 删除包含停用词的名词短语
- c++ - “thrift -gen cpp”生成的代码在 macOS 上无法编译:找不到“boost/tr1/functional.hpp”文件
- python-3.x - 正确切割大配合文件以将某些星系隔离成较小配合文件的方法
- ocaml - Ocaml 使用换行符打印到文件
- python - python/pandas/一维数据框
- haskell - 猜一个函数的输入?
- java - RxJava 1.x:如何在单元测试中模拟背压
- java - JAVA可折叠垂直布局
- javascript - 我的 Vue 数据有问题(组件渲染问题)