Created
October 7, 2011 08:29
-
-
Save Ajnasz/1269771 to your computer and use it in GitHub Desktop.
Precommit hook for git to check js syntax
This file contains 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 | |
# Precommit hook to check js syntax | |
gitstatus=$(git st --short | awk '/^M.+js$/ {print $2}'); | |
echo $gitstatus | while read i; do | |
if [ ! -z "$i" ]; then | |
echo "parse: $i"; | |
output=$(js -e "parse(read('$i'))" 2>&1); | |
if [ ! -z "$output" ]; then | |
echo $output; | |
exit 1; | |
fi; | |
fi; | |
done; | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment