I am currently using Jest, Husky, Commitizen, and Vuepress. However, when jest tests or the build fails, the commit hook still works. How can I fix this to exit the commitizen hook when things fail? Here is the relevant lines in package.json:
{
"scripts": {
"build": "vuepress build docs
"lint": "eslint --fix --ext .js,.vue docs/.vuepress",
"test": "npm run lint && jest --coverage --coverageDirectory='__coverage__'",
"test:full": "npm run test && npm run build",
"commit": "cz",
...
},
"husky": {
"hooks": {
"prepare-commit-msg": "npm run test:full && exec < /dev/tty && git cz --hook || true"
}
},
"dependencies": {
...
},
"devDependencies": {
"babel-jest": "^26.6.3",
"commitizen": "^4.2.3",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.18.0",
"husky": "^4.3.8",
"jest": "^26.6.3",
...
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
Figured it out - it was simple. I needed to add the following to husky:
"husky": {
"hooks": {
"pre-commit": "npm run test:full",
...
}
},