mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 18:15:39 +00:00
setup librejs license and cachebust service worker file
This commit is contained in:
41
scripts/cachebust.sh
Executable file
41
scripts/cachebust.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
trap cleanup SIGINT SIGTERM ERR EXIT
|
||||
|
||||
readonly PROJECT_ROOT=$(realpath $(dirname $(dirname "${BASH_SOURCE[0]}")))
|
||||
source $PROJECT_ROOT/scripts/lib.sh
|
||||
|
||||
readonly DIST=$PROJECT_ROOT/static/cache/bundle/
|
||||
|
||||
|
||||
file_extension() {
|
||||
echo $1 | rev | tr
|
||||
}
|
||||
|
||||
cache_bust(){
|
||||
name=$(get_file_name $1)
|
||||
extension="${name##*.}"
|
||||
filename="${name%.*}"
|
||||
file_hash=$(sha256sum $1 | cut -d " " -f 1 | tr "[:lower:]" "[:upper:]")
|
||||
|
||||
msg "${GREEN}- Processing $name: $filename.$file_hash.$extension"
|
||||
|
||||
sed -i \
|
||||
"s/$name/assets\/bundle\/$filename.$file_hash.$extension/" \
|
||||
$(find $DIST -type f -a -name "*.js")
|
||||
}
|
||||
|
||||
setup_colors
|
||||
|
||||
msg "${BLUE}[*] Setting up files for cache busting"
|
||||
|
||||
for file in $(find $DIST -type f -a -name "*.js")
|
||||
do
|
||||
name=$(get_file_name $file)
|
||||
case $name in
|
||||
"bench.js")
|
||||
cache_bust $file
|
||||
;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user