diff --git a/config/retrodeck/reference_lists/bios.json.tmp b/config/retrodeck/reference_lists/bios.json.tmp new file mode 100644 index 00000000..e69de29b diff --git a/developer_toolbox/hooks/pre-commit b/developer_toolbox/hooks/pre-commit index 31210b0a..32a4a16b 100755 --- a/developer_toolbox/hooks/pre-commit +++ b/developer_toolbox/hooks/pre-commit @@ -1,15 +1,21 @@ #!/bin/bash -# A pre-commit hook to lint features.json if it is edited +# A pre-commit hook to lint json files if it they're edited -# Check if any path contains 'features.json' -if git diff --cached --name-only | grep -q 'config/retrodeck/reference_lists/features.json'; then - # Run the linting script - echo "Linting config/retrodeck/reference_lists/features.json..." - if ! bash developer_toolbox/lint_features.json.sh; then - echo "Linting failed. Please fix the issues and try again." - exit 1 # Exit with a non-zero status to block the commit +lint_list=( + "config/retrodeck/reference_lists/features.json" + "config/retrodeck/reference_lists/bios.json" + ) + +for file in "${lint_list[@]}"; do + if git diff --cached --name-only | grep -q "$file"; then + # Run the linting script + echo "Linting $file..." + if ! bash "developer_toolbox/lint_json.sh" "$file"; then + echo "Linting failed for \"$(basename $file)\". Please fix the issues and try again." + exit 1 # Exit with a non-zero status to block the commit + fi fi -fi +done # Lint Manifest # if git diff --cached --name-only | grep -q 'net.retrodeck.retrodeck.yml'; then diff --git a/developer_toolbox/lint_features.json.sh b/developer_toolbox/lint_features.json.sh deleted file mode 100755 index 22140f06..00000000 --- a/developer_toolbox/lint_features.json.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -features=config/retrodeck/reference_lists/features.json - -jq . $features > $features.tmp && mv -f $features.tmp $features \ No newline at end of file diff --git a/developer_toolbox/lint_json.sh b/developer_toolbox/lint_json.sh new file mode 100755 index 00000000..ae825c50 --- /dev/null +++ b/developer_toolbox/lint_json.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +json=$1 + +jq . $json > $json.tmp && mv -f $json.tmp $json \ No newline at end of file