Skip to content

Commit e5e4d07

Browse files
committed
fix: fix logs and prevent empty normalisation
1 parent 09f6f71 commit e5e4d07

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

src/common-utils/_configure-feature.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ for package in package composer; do
7777
echo "{}" >$package.json
7878
else
7979
# Pre-sort the existing package.json
80+
echo "${Yellow}Pre-merge normalize $package.json${None}"
8081
normalize-json -t ${tabSize:-4} $package.json
8182
fi
8283

8384
# Merge all package folder json files into the top-level package.json
8485
find $source -maxdepth 1 -name _*.$package.json | sort | while read file; do
85-
echo "${Yellow}Merge $file${None}"
86+
echo "${Yellow}Merge $file in $package.json${None}"
8687
jq --indent ${tabSize:-4} -s '.[0] * .[1]' $file $package.json >/tmp/$package.json && mv -f /tmp/$package.json $package.json
8788
done
8889

src/common-utils/_normalize-json.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -608,12 +608,16 @@ if validate "$json" "$schema"; then
608608
else
609609
echo -e "${Red}JSON is empty or invalid${None}" >&2
610610
exit 1
611-
fi | traverse $json >/tmp/$$.json
611+
fi >/tmp/$$.json
612612

613-
if test -z "$save"; then
614-
jq -C --indent ${tabSize:-2} . /tmp/$$.json
615-
else
616-
jq -M --indent ${tabSize:-4} . /tmp/$$.json >$json
613+
# Handle output
614+
if test -s /tmp/$$.json; then
615+
if test -z "$save"; then
616+
traverse $json /tmp/$$.json | jq -C --indent ${tabSize:-2} .
617+
else
618+
traverse $json /tmp/$$.json | jq -M --indent ${tabSize:-4} . >$json
619+
fi
617620
fi
618621

619-
#rm -f /tmp/$$.json
622+
# Clean up
623+
rm -f /tmp/$$.json

src/common-utils/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Common Utils",
3-
"version": "3.3.0",
3+
"version": "3.3.2",
44
"description": "Common utils for tomgrv/devcontainer-features",
55
"dependsOn": {
66
"ghcr.io/devcontainers/features/common-utils": {}

0 commit comments

Comments
 (0)