From 975e4d21841ef6150508318e12570d164f885ea8 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Sun, 12 Oct 2025 14:14:45 +0000 Subject: [PATCH] fixup cachebust when sprites change but script.js doesn't otherwise change --- cachebust.list | 1 - cachebust.sh | 17 +++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cachebust.list b/cachebust.list index e8681aa..dd353ef 100644 --- a/cachebust.list +++ b/cachebust.list @@ -8,5 +8,4 @@ layers.js markers.js planeObject.js registrations.js -script.js style.css diff --git a/cachebust.sh b/cachebust.sh index 79fddd5..78895e8 100755 --- a/cachebust.sh +++ b/cachebust.sh @@ -13,18 +13,23 @@ HTMLFOLDER="$2" sedreplaceargs=() -SCRIPT_JS="" -while read -r FILE; do +function moveFile() { + FILE=$1 md5sum=$(md5sum "$FILE" | cut -d' ' -f1) prefix=$(cut -d '.' -f1 <<< "$FILE") postfix=$(cut -d '.' -f2 <<< "$FILE") newname="${prefix}_${md5sum}.${postfix}" mv "$FILE" "$newname" sedreplaceargs+=("-e" "s#${FILE}#${newname}#") - if [[ "$FILE" == "script.js" ]]; then - SCRIPT_JS="$newname" - fi +} + +while read -r FILE; do + moveFile "$FILE" done < "$LISTPATH" +sed -i "${sedreplaceargs[@]}" "$HTMLFOLDER"/script.js + +# this needs to happen after it was modified +moveFile script.js + sed -i "${sedreplaceargs[@]}" "$HTMLFOLDER"/index.html -sed -i "${sedreplaceargs[@]}" "$HTMLFOLDER"/"$SCRIPT_JS"