polarity/scripts/check_examples_index.sh
Tim Süberkrüb 86f9994473
Add examples/index.json (#397)
* Add examples/index.json

* Ensure examples index remains in sync

* Improve script output

* Set permissions in .github/workflows/examples-index.yml
2024-11-29 23:21:03 +01:00

17 lines
582 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
# Get the list of .pol files in the examples directory
pol_files=$(find examples -maxdepth 1 -name "*.pol" -printf "%f\n" | sort)
# Extract the 'path' entries from index.json
index_paths=$(jq -r '.[].path' examples/index.json | sort)
# Compare the two lists
if diff <(echo "$pol_files") <(echo "$index_paths") >/dev/null; then
echo "Success: examples/index.json and examples/*.pol files are in sync."
else
echo "Error: examples/index.json and examples/*.pol are not in sync."
echo "Diff:"
diff <(echo "$pol_files") <(echo "$index_paths")
fi