Created
June 8, 2017 19:25
-
-
Save wesvetter/e04ad4915d1d72cb234972b6eefe1e55 to your computer and use it in GitHub Desktop.
git hook to run npm tests before pushing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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