Created
March 31, 2012 02:10
-
-
Save joshuacc/2258630 to your computer and use it in GitHub Desktop.
isitgoodjs
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 | |
if [ "$1" == "" ]; then | |
echo -e "\e[00;32mPlease specify a JavaScript file to check." | |
exit 1 | |
fi | |
git rev-parse --git-dir 1>/dev/null 2>&1 | |
if [ $? != 0 ]; then | |
echo -e "\n\033[00;41;30mYou are not in a git repository.\033[00m\n" | |
exit 1 | |
else | |
CONFIG=$(git rev-parse --git-dir)/hooks/jshint-config.json | |
if [ ! -e "$CONFIG" ]; then | |
echo -e "\n\033[00;41;30mThe JSHint config file is missing from your git repository.\033[00m\n" | |
exit 1 | |
fi | |
fi | |
ERRORS=$(jshint $1 --config $(git rev-parse --git-dir)/hooks/jshint-config.json >&1) | |
if [ $? != 0 ]; then | |
if [ "$ERRORS_BUFFER" != "" ]; then | |
ERRORS_BUFFER="$ERRORS_BUFFER\n- $ERRORS" | |
else | |
ERRORS_BUFFER="- $ERRORS" | |
fi | |
echo "$ERRORS" | |
fi | |
if [ "$ERRORS_BUFFER" != "" ]; then | |
echo | |
echo -e "\033[00;41;30mNo good. :(\033[00m\n" | |
exit 1 | |
else | |
echo -e "\n\033[00;42;30mAnd it was good. :)\033[00m\n" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment