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"