fixup cachebust when sprites change but script.js doesn't otherwise change

This commit is contained in:
Matthias Wirth
2025-10-12 14:14:45 +00:00
parent 99f4d35601
commit 975e4d2184
2 changed files with 11 additions and 7 deletions

View File

@@ -8,5 +8,4 @@ layers.js
markers.js
planeObject.js
registrations.js
script.js
style.css

View File

@@ -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"