-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
export.sh
executable file
·33 lines (28 loc) · 887 Bytes
/
export.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /usr/bin/env bash
rm -rf app/js/*
gmake build
declare -A filenames
for file in app/js/app*.js app/js/main*.js; do
checksum=$(b3sum --no-names -- "$file")
basename=$(basename "$file")
if [[ "$checksum" != "*$basename*" ]]; then
mv "$file" "app/js/${checksum}-${basename}"
filenames["$basename"]="${checksum}-${basename}"
fi
done
for file in html/css/*.css; do
checksum=$(b3sum --no-names -- "$file")
basename=$(basename "$file")
if [[ "$checksum" != "*$basename*" ]]; then
cp "$file" "app/css/${checksum}-${basename}"
filenames["$basename"]="${checksum}-${basename}"
fi
done
cd html
for html in *.html **/*.html; do
mkdir -p "../app/$(dirname $html)"
cp "$html" "../app/$html"
for basename in "${!filenames[@]}"; do
sed -i '' "s;${basename};${filenames[$basename]};" "../app/$html"
done
done