sort-json 307 B

123456789101112131415161718
  1. #!/bin/sh
  2. if [ -z "$(command -v jq)" ]; then
  3. echo "Usage: $0" >&2
  4. echo "Dependencies: jq" >&2
  5. exit 1
  6. fi
  7. for f in $(find source/db -name \*.json); do
  8. jq -S 'sort_by(.slug)' $f > $f.bak
  9. mv $f.bak $f
  10. done
  11. for f in $(find source/locales -name \*.json); do
  12. jq -S . $f > $f.bak
  13. mv $f.bak $f
  14. done