From 25c2f8c101d6eec1ad8f182080b6cc7efb2f564d Mon Sep 17 00:00:00 2001 From: goldsquid Date: Fri, 19 Dec 2025 13:07:14 +0700 Subject: [PATCH] more clear --- show-size.sh | 3 +++ show-static-file-size.sh | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/show-size.sh b/show-size.sh index 146c55be..3f35aa97 100755 --- a/show-size.sh +++ b/show-size.sh @@ -33,6 +33,8 @@ for part in "${parts[@]}"; do fi if $include; then + echo "Checking ${part%.yml}..." >&2 + # Capture stdout (ratio) while letting stderr display naturally static_ratio="$($BASEPATH/show-static-file-size.sh ${part%.yml})" static_ratio="0$static_ratio" total_kb=$($BASEPATH/show-file-size.sh ${part%.yml}) @@ -46,6 +48,7 @@ for part in "${parts[@]}"; do static_size=$(echo "$static_size + $static_part" | bc) #output=$(echo "$static_size" | numfmt --to=iec --suffix=B --format="%.2f") #echo "$output" + echo "" >&2 fi done diff --git a/show-static-file-size.sh b/show-static-file-size.sh index 8face440..49f1be66 100755 --- a/show-static-file-size.sh +++ b/show-static-file-size.sh @@ -22,11 +22,18 @@ for key in $keys; do # Print the size of the file or directory size=$(du -sL "$prefix/_data/$path" 2>/dev/null | awk '{print $1}') static_size=$((static_size + size)) - # Print the detected path to stderr so it doesn't interfere with ratio output - echo "$prefix/_data/$path" >&2 + # Format size in human-readable format + size_formatted=$(echo "$(( size * 1024 ))" | numfmt --to=iec --suffix=B --format="%.2f") + # Print the detected path with size to stderr (one per line) + echo "$size_formatted $prefix/_data/$path" >&2 fi done < static-file-path-list.txt done +# Print total static size to stderr +static_total_formatted=$(echo "$(( static_size * 1024 ))" | numfmt --to=iec --suffix=B --format="%.2f") +echo "---" >&2 +echo "Total static: $static_total_formatted" >&2 + ratio=$(bc -l <<< "scale=2; $static_size/$total_size") echo "$ratio"