Skip to content

Commit

Permalink
Print diffstat when sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
garyhtou committed Aug 15, 2024
1 parent 205233e commit bc116be
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/sort
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
yq '.zones | keys | .[]' config/production.yaml | while read -r zone; do
# For each file...
FILENAME="$zone"yaml
echo Sorting $FILENAME
echo -e "\nSorting $FILENAME"

# Sort the keys in the file
# Print a diff (if changes are made)
yq -MP 'sort_keys(.)' $FILENAME >$FILENAME.tmp
diff -u $FILENAME $FILENAME.tmp | diffstat -q
rm $FILENAME.tmp

# Apply the changes
yq -iMP 'sort_keys(.)' $FILENAME
# - i: in-place
# - M: no color
Expand Down

0 comments on commit bc116be

Please sign in to comment.