I am using NestJs for my new project.
I am adding all the files with this command. git add .
when I commit after adding all the files husky prevents committing and shows me this error.
[path to the file]/.spec.ts' is not included in the project.
husky > pre-commit hook failed (add --no-verify to bypass)
I implicitly added the file but It still throwing me that error.
my tsconfig.json file
{
"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"]
}
and this is how I added husky commands in the package.json file
"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