Skip to content

Instantly share code, notes, and snippets.

@mebibou
Created February 2, 2015 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mebibou/554f3563bdc4c8bb624f to your computer and use it in GitHub Desktop.
Save mebibou/554f3563bdc4c8bb624f to your computer and use it in GitHub Desktop.
npm test pre-push on dev branch
#!/bin/sh
# pre-push git hook.
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
pass=true
if [ $current_branch = "dev" ]; 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