Created
October 29, 2015 23:28
-
-
Save sterpe/e43a1d5549c96cdd1d97 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# This is a utility command to clean up the various constants files. | |
# | |
# Usage is : ./scripts/constants.sh <file> | |
# It will alphabetize keys, and if any key is an array, it will | |
# alphabetize or order that array. | |
# It does not support multi-level nested objects but objects that | |
# look like this: { "key": "value" } or { "key": [] } only. | |
# The script requires that both `ed` and `jq` are on the $PATH. | |
ed -s $1 << EOF | |
H | |
\$-kx | |
\$r ! jq -S ' . | map_values( . as \$o | . = try sort catch \$o ) ' $1 | |
1,'x+d | |
w | |
q | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment