Last active
December 22, 2020 15:10
-
-
Save edasque/ab826eb94aae97239132 to your computer and use it in GitHub Desktop.
pre-commit Git hook to JSONlint - place it in .git/hooks
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 | |
git diff-index -z --cached HEAD --name-only --diff-filter=ACMRTUXB | | |
xargs -0 -t -L1 /usr/local/bin/jsonlint -c; | |
if [ "$?" != "0" ]; then | |
echo "\nOne or more JSON file didn't pass jsonlint'ing."; | |
echo "Fix them before committing. If it is not possible to fix them all commit with the option --no-verify."; | |
exit 1; | |
fi |
// , Nice work. This was the third result in my search for jsonlint hook.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works on a mac. xargs is a little bit different on linux where it probably should be changed to
xargs --null --no-run-if-empty /usr/local/bin/jsonlint -c;
.This assumes jsonlint 1.6.x is installed in /usr/local/bin