Last active
June 2, 2016 15:19
-
-
Save kylebradshaw/221d6e8cffd91a40eeca547ec055b8f3 to your computer and use it in GitHub Desktop.
Revisions
-
kylebradshaw revised this gist
Jun 2, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ if [ "$files" = "" ]; then fi valid=true echo "\033[96m= Validating JavaScript with JSHint... \033[0m" for file in ${files}; do result=$(jshint ${file} --config .jshintrc) if [ "$result" == "" ]; then @@ -34,7 +34,7 @@ fi ###################################################################### # Unit Tests: Run unit tests/specs before committing ###################################################################### echo "\033[96m= Running Karma... \033[0m" gulp karma 1> /dev/null EXIT_CODE=$? if [[ ${EXIT_CODE} -ne 0 ]]; then -
kylebradshaw created this gist
Jun 2, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ #!/bin/sh # Kyle's Hook ###################################################################### # JSHint: Run JS formatting before committing ###################################################################### files=$(git diff --cached --name-only --diff-filter=ACM | grep ".js$") if [ "$files" = "" ]; then echo "no Files" fi valid=true echo "\033[96m===== Validating JavaScript with JSHint =====\033[0m" for file in ${files}; do result=$(jshint ${file} --config .jshintrc) if [ "$result" == "" ]; then echo "\033[32m JSHint Passed for: ${file} \033[0m" else echo "\033[31m JSHint Failed for: ${file} \033[0m" valid=false fi done # echo '\n\n' "\033[96m===== JavaScript validation complete. =====\033[0m" if ${valid}; then echo "\033[42m \033[30mCOMMIT SUCCEEDED: JSHINT FTW!! \033[0m" # printf '\n%s\n' "JSHint Succeeded" else echo "\033[41m COMMIT FAILED: JSHINT FTL.. \033[0m" # printf '\n%s\n' "Commit Failed: Please fix all above JSHint errors and try again" exit 1 fi ###################################################################### # Unit Tests: Run unit tests/specs before committing ###################################################################### echo "\033[96m===== Running Karma... =====\033[0m" gulp karma 1> /dev/null EXIT_CODE=$? if [[ ${EXIT_CODE} -ne 0 ]]; then # echo "[ERROR] code = " ${EXIT_CODE} # echo "Karma Unit Tests failed." # echo "Commit aborted." echo "\033[41m COMMIT ABORTED: KARMA FTL.. \033[0m" exit 1 else echo "\033[42m\033[30m COMMIT SUCCEEDED: KARMA FTW!! \033[0m" fi