Skip to content

Instantly share code, notes, and snippets.

@hamzaPixl
Last active December 4, 2018 11:11
Show Gist options
  • Select an option

  • Save hamzaPixl/b0ec47039a90698e4dbfbc7956bdae7f to your computer and use it in GitHub Desktop.

Select an option

Save hamzaPixl/b0ec47039a90698e4dbfbc7956bdae7f to your computer and use it in GitHub Desktop.
Run test before pushing
{
"hooks": {
"pre-push": "hooks/check-no-console-call.sh && hooks/run-test-prepush.sh"
}
}
#!/bin/sh
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
pass=true
if [ $current_branch = "devlop" ] || [ $current_branch = "master" ]; then
npm test
if [ $? != 0 ]; then
pass=false
fi
fi
if $pass; then
exit 0
else
echo ""
echo "PUSH FAILED:"
echo "Some tests fail. Please fix them and try pushing again."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment