Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasBurleson/6611150 to your computer and use it in GitHub Desktop.
Save ThomasBurleson/6611150 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Pre-commit hooks
######################################################################
# Environment Setup
# 1) Change directory to build dir so we can run grunt tasks.
# 2) Make sure path is extended to include grunt task executable
# dir, as this commit shell is executed in the git
# client's own shell; ie Tower and WebStorm have own shell path.
######################################################################
cd build
PATH=$PATH:~/usr/local/bin
PATH=$PATH:/usr/local/bin
######################################################################
# JSHint: Lint stuff before committing
######################################################################
grunt jshint
EXIT_CODE=$?
# echo ${EXIT_CODE}
if [[ ${EXIT_CODE} -ne 0 ]]; then
echo "[ERRROR] code = " ${EXIT_CODE}
echo "JSHint detected syntax problems."
echo "Commit aborted."
exit 1
else
echo "JSHint completed successfully\n"
fi
######################################################################
# Unit Tests: Run unit tests/specs before committing
######################################################################
grunt karma:continuous
EXIT_CODE=$?
if [[ ${EXIT_CODE} -ne 0 ]]; then
echo "[ERRROR] code = " ${EXIT_CODE}
echo "Karma Unit Tests failed."
echo "Commit aborted."
exit 1
else
echo "Karma Unit Tests completed successfully\n"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment