Created
May 21, 2018 13:54
-
-
Save Upliner/6480e6b91747135db45fdccf56b7e50e to your computer and use it in GitHub Desktop.
The git hook that checks validity of .json files in the repository
This file contains 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 | |
exec 1>&2 | |
git diff --cached --name-only --diff-filter=d -z HEAD | while IFS= read -r -d '' file ; do | |
if [ "${file##*.}" = "json" ]; then | |
if ! cat $file | python -m json.tool > /dev/null; then | |
echo $file | |
exit 1 | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment