Skip to content

Commit a7994e8

Browse files
committed
Print diffstat when sorting
1 parent 7455e3a commit a7994e8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

bin/sort

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
yq '.zones | keys | .[]' config/production.yaml | while read -r zone; do
55
# For each file...
66
FILENAME="$zone"yaml
7-
echo Sorting $FILENAME
7+
echo -e "\nSorting $FILENAME"
88

9-
# Sort the keys in the file
9+
# Print a diff (if changes are made)
10+
yq -MP 'sort_keys(.)' $FILENAME >$FILENAME.tmp
11+
diff -u $FILENAME $FILENAME.tmp | diffstat -q
12+
rm $FILENAME.tmp
13+
14+
# Apply the changes
1015
yq -iMP 'sort_keys(.)' $FILENAME
1116
# - i: in-place
1217
# - M: no color

0 commit comments

Comments
 (0)