Last active
October 15, 2017 06:37
-
-
Save abachman/000f14c1b471dce226efc7a934d897e5 to your computer and use it in GitHub Desktop.
A git pre commit hook for adafruit/io-api developers
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/sh | |
# check modified JSON files | |
files=$(git diff --cached --name-only --diff-filter=ACM | grep "v[12].json$") | |
if [ "$files" = "" ]; then | |
exit 0 | |
fi | |
pass=true | |
if [ -f node_modules/.bin/jsonlint ]; then | |
echo "\nValidating JSON:\n" | |
for file in ${files}; do | |
node_modules/.bin/jsonlint ${file} | |
if [ $? -ne 0 ]; then | |
echo "\n\033[31m${file} is invalid, git commit blocked\033[0m" | |
exit 1 | |
fi | |
done | |
else | |
echo "\n\033[33mjsonlint is not installed, run \`npm install\` before committing v1.json or v2.json\033[0m" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment