Skip to content

Test for shfmt #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions scripts/jq_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
EXIT_CODE=0
FILES=$(find . -name "*.json")
for FILE in $FILES; do
if jq . "$FILE" >"$FILE.temp" 2>"$FILE.err"; then
if ! diff --unified "$FILE" "$FILE.temp" >"$FILE.diff"; then
EXIT_CODE=1
if [ "$1" == "--diff" ]; then
cat "$FILE.diff"
elif [ "$1" == "--apply" ]; then
cp "$FILE.temp" "$FILE"
else
printf "%s;; \`jq\` would format this file. Use \`./scripts/jq_format.sh --diff\` to see the changes it would make and \`./scripts/jq_format.sh --apply\` to apply them.\n" "$FILE"
fi
fi
rm "$FILE.diff"
if jq . "$FILE" >"$FILE.temp" 2>"$FILE.err"; then
if ! diff --unified "$FILE" "$FILE.temp" >"$FILE.diff"; then
EXIT_CODE=1
if [ "$1" == "--diff" ]; then
cat "$FILE.diff"
elif [ "$1" == "--apply" ]; then
cp "$FILE.temp" "$FILE"
else
printf "%s;; \`jq\` would format this file. Use \`./scripts/jq_format.sh --diff\` to see the changes it would make and \`./scripts/jq_format.sh --apply\` to apply them.\n" "$FILE"
fi
fi
rm "$FILE.temp"
rm "$FILE.err"
rm "$FILE.diff"
fi
rm "$FILE.temp"
rm "$FILE.err"
done

exit "$EXIT_CODE"
6 changes: 4 additions & 2 deletions scripts/jq_valid.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
EXIT_CODE=0
FILES=$(find . -name "*.json")
for FILE in $FILES; do
if ! jq . "$FILE" >"$FILE.temp" 2>"$FILE.err"; then
for FILE in $FILES;
do
if ! jq . "$FILE" >"$FILE.temp" 2>"$FILE.err";
then
EXIT_CODE=1
printf "%s;;%s\n" "$FILE" "$(<"$FILE.err")"
fi
Expand Down