From d590511be4f373389a89182ce4fc8eccbab9fa0b Mon Sep 17 00:00:00 2001 From: Nick Nisi Date: Sat, 15 Aug 2015 08:33:32 -0500 Subject: [PATCH] fix jshint pre-commit hook * fix issue with hook apparently not recognizing javascript files * add check for existence of jshint and, quit without errors --- git/hooks/jshint.pre-commit | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/git/hooks/jshint.pre-commit b/git/hooks/jshint.pre-commit index f3908ef..9b51971 100755 --- a/git/hooks/jshint.pre-commit +++ b/git/hooks/jshint.pre-commit @@ -5,13 +5,19 @@ EXIT_CODE=0 COLOR_RED="\x1B[31m" +COLOR_YELLOW="\x1B[1;33m" COLOR_GREEN="\x1B[32m" COLOR_NONE="\x1B[0m" +if ! jshint > /dev/null 2>&1; then + echo "${COLOR_YELLOW}JSHint is not installed. Exiting.${COLOR_NONE}" + exit 0 +fi + repo=$( git rev-parse --show-toplevel ) for file in $( exec git diff-index --cached --name-only HEAD ); do - if [[ $file == *".js$"* ]]; then + if [ ${file: -3} == ".js" ]; then status=$( exec git status --porcelain $file ) if [[ $status != D* ]]; then