pre-push in husky not work when my test fail in nest js

73 Views Asked by At

this is my husky version that i was installed: "husky": "^8.0.3", and also my husky config in package.json :

   "hooks": {
     "prepare-commit-msg": "commitlint -E HUSKY_GIT_PARAMS && ln -s -f /.husky/prepare-commit-msg .git/hooks/prepare-commit-msg",
     "pre-push": "npm run test || (echo 'Tests failed' && exit 1)"
   }
 }, 

and also this is my pre-push bash script in .husky folder :

. "$(dirname -- "$0")/_/husky.sh"

npm run test
if [ $? -ne 0 ]; then
  echo "Tests failed. Aborting push."
  exit 1
fi 

when I run test when It fail, it also push the code , how can i fix this when the test fail it doesn't push

0

There are 0 best solutions below