Skip to content

Instantly share code, notes, and snippets.

@wesvetter
Created June 8, 2017 19:25
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 wesvetter/e04ad4915d1d72cb234972b6eefe1e55 to your computer and use it in GitHub Desktop.
Save wesvetter/e04ad4915d1d72cb234972b6eefe1e55 to your computer and use it in GitHub Desktop.
git hook to run npm tests before pushing
#!/bin/bash
RUN_TESTS="npm test"
# Only run the tests if we actually have commits to push
commits=`git log @{u}..`
if [ -z "$commits" ]; then
exit 0
fi
$RUN_TESTS
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "failed $RUN_TESTS"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment