Last active
August 29, 2015 14:14
-
-
Save winkerVSbecks/73b3dfda4c3a17bf76c2 to your computer and use it in GitHub Desktop.
Run JSHint validation before commit
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 | |
| # | |
| # Run JSHint validation before commit. | |
| files=$(git diff --cached --name-only --diff-filter=ACM | grep '.js$') | |
| pass=true | |
| # JSHint | |
| if [ "$files" != "" ]; then | |
| for file in ${files}; do | |
| jshint ${file} | |
| if [[ $? -ne 0 ]]; then | |
| pass=false | |
| fi | |
| done | |
| fi | |
| if $pass; then | |
| exit 0 | |
| else | |
| echo "" | |
| echo "COMMIT FAILED:" | |
| echo "Some JavaScript files are invalid. Please fix errors and try committing again." | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment