File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 5050TEMP_FILE=$( mktemp)
5151
5252# Download the file
53- echo " Downloading $URL ... "
53+ echo " Downloading $URL "
5454curl -s -L " $URL " -o " $TEMP_FILE " || {
5555 echo " Error: Failed to download $URL "
5656 rm -f " $TEMP_FILE "
7575CURRENT_DIR=" $( pwd) "
7676FULL_PATH=" ${CURRENT_DIR} /${FILENAME} "
7777
78+ # Pretty-print JSON if applicable
79+ if [ " $EXTENSION " = " .json" ]; then
80+ # Create another temporary file for the pretty-printed version
81+ PRETTY_TEMP=$( mktemp)
82+ # Try to pretty-print with jq, but don't fail if jq fails
83+ if command -v jq & > /dev/null; then
84+ if jq . " $TEMP_FILE " > " $PRETTY_TEMP " 2> /dev/null; then
85+ mv " $PRETTY_TEMP " " $TEMP_FILE "
86+ else
87+ rm -f " $PRETTY_TEMP "
88+ fi
89+ else
90+ rm -f " $PRETTY_TEMP "
91+ fi
92+ fi
93+
7894# Move to final destination
7995mv " $TEMP_FILE " " $FULL_PATH "
80-
You can’t perform that action at this time.
0 commit comments