#! /usr/bin/env bash set -euo pipefail SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" # Find all JSON files but ignore any that are also ignored by git (e.g. IDE settings files). JSON_FILES=$(find \ $SCRIPTPATH/../../ \ -name "*.json" \ -type f \ -not -exec git check-ignore --quiet {} \; \ -print) FAILED_FILES=() if [[ -z `which python` ]] && [[ ! -z `which python3` ]]; then PY=python3 else PY=python fi for j in $JSON_FILES; do echo "validating $j" $PY -mjson.tool "$j" > /dev/null || FAILED_FILES+=("$j") done if [[ ${#FAILED_FILES[@]} -eq 0 ]]; then echo "✅ json-validator found no errors!" else echo "❌ JSON syntax errors found in these files: ${FAILED_FILES[*]}" exit 1 fi