diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2021-02-09 10:50:55 +0100 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2021-02-09 10:50:55 +0100 |
commit | b806f13c1a022982d690dea3e59412b45bf336ed (patch) | |
tree | 52658cbe39219047d2af2d044039e26b68964829 /postbuild.sh | |
parent | 3125ad62e4f7cc7532e6f8b8c664b4863f58acd7 (diff) | |
download | hoverbit-ble-b806f13c1a022982d690dea3e59412b45bf336ed.tar.gz hoverbit-ble-b806f13c1a022982d690dea3e59412b45bf336ed.zip |
:hammer: Add postbuild-script
Diffstat (limited to 'postbuild.sh')
-rwxr-xr-x | postbuild.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/postbuild.sh b/postbuild.sh new file mode 100755 index 0000000..c1f0ffc --- /dev/null +++ b/postbuild.sh @@ -0,0 +1,33 @@ +#!/bin/bash +PUBLISH_URL="/hoverbit-ble/" + +cd "dist" || exit 1 + +VERSION=$(cat ../package.json \ + | grep version \ + | head -1 \ + | awk -F: '{ print $2 }' \ + | sed 's/[",]//g' \ + | tr -d '[[:space:]]') + +tput setaf 4; echo "> Add service-worker.js..."; tput sgr0 +cp ../src/service-worker.js ./service-worker.js + +tput setaf 4; echo "> Add version number to files ($VERSION)..."; tput sgr0 +sed -i".bak" "s/{{ VERSION }}/$VERSION/g" index.html +sed -i".bak" "s/{{ VERSION }}/$VERSION/g" service-worker.js + +tput setaf 4; echo "> Add cache-files to webmanifest..."; tput sgr0 +cache_files="'$PUBLISH_URL'"; +for file in *; do + if [[ "$file" =~ (manifest.webmanifest|*.git) ]]; then + continue + fi + cache_files="$cache_files,""'$PUBLISH_URL$file'" +done +sed -i".bak" "s|\"{{ CACHE_FILES }}\"|$cache_files|g" service-worker.js + +tput setaf 4; echo "> Remove .bak-files..."; tput sgr0 +rm *.bak + +cd .. |