Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mpdaugherty/432727 to your computer and use it in GitHub Desktop.
Save mpdaugherty/432727 to your computer and use it in GitHub Desktop.
# Turn off ambiguous end of line errors; they conflict with standard jQuery syntax
-ambiguous_newline
# cd into the root code directory
cd `git rev-parse --show-cdup`.
diffJSFiles=`git diff origin/master HEAD --name-only | grep "\.js$"`
echo "Validating Javascript Files with JS Lint:"
echo "$diffJSFiles"
jsPassed=0
for jsFile in $diffJSFiles; do
# Replace bin/jslint/jsl below with the path to jsl on your system. I added it to our
# repository so that new developers wouldn't have to set anything up and this script would
# immediately work
if bin/jslint/jsl -process $jsFile -conf bin/jslint/jsl.conf 2>&1 | grep 'lint' ; then
jsPassed=1
fi
done
if [ $jsPassed = 1 ]
then
echo "JSLint failed. Refusing push."
exit 1
fi
echo 'JSLint Succeeded - Pushing'
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment