-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunbuild
More file actions
executable file
·49 lines (36 loc) · 1.24 KB
/
unbuild
File metadata and controls
executable file
·49 lines (36 loc) · 1.24 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
#
# find all html files in the ./dist directory and patch the original
# template files.
for html in $(find dist -name *.html); do
template=$(sed -r -e 's:/(.*!/)?index\.html:\1\.mustache:' -e 's:^dist:templates:' <<<$html)
if [[ $template == "templates.mustache" ]]; then
template=templates/index.mustache
fi
if [[ ! -f $template ]]; then
echo "There is no such file $template. Abort."
exit 1
fi
content=`mktemp --tmpdir=.`
sed -n '/<!-- CONTENT-STARTS -->/,/<!-- CONTENT-ENDS -->/p' $html \
| grep -Ev '<!-- CONTENT-(STARTS|ENDS) -->' > $content
sed -i '${/^$/d;}' $content
diff -u $template $content > "$content.patch"
if [[ -s "$content.patch" ]]; then
cat "$content.patch"
echo "Apply patch? (y/N)"
read answer
if [[ $answer == "y" ]]; then
patch -sf -o $template < "$content.patch"
else
echo "Skipping patch..."
fi
fi
rm $content "$content.patch"
git diff $template
# diff $html <(sed -r -e 's:\.html$:\.template' -e 's:^dist:templates' <<<$html)
done
# while read path; do
# echo "-> $path"
# html=$(sed -r 's:.template$/.html' <<<$path)
# done <routes.tsv