Last active
December 4, 2018 11:11
-
-
Save hamzaPixl/b0ec47039a90698e4dbfbc7956bdae7f to your computer and use it in GitHub Desktop.
Run test 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
| { | |
| "hooks": { | |
| "pre-push": "hooks/check-no-console-call.sh && hooks/run-test-prepush.sh" | |
| } | |
| } |
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/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