-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·46 lines (34 loc) · 1.34 KB
/
package.sh
File metadata and controls
executable file
·46 lines (34 loc) · 1.34 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
#!/usr/bin/env bash
rm -rf dist
rm -f package.log
touch package.log 2> /dev/null
# -- TYPESCRIPT FILES --
echo '== processing typescript files' | tee -a package.log
# compile typescript files
echo ' `-- transpiling ts files' | tee -a package.log
yarn run 'ts:build' >> package.log
# -- RIOT TAGS --
echo '== processing riot tags files' | tee -a package.log
# compile riot tags to es5
echo ' |-- compiling tags to es5' | tee -a package.log
yarn run 'riot:build' >> package.log
# remove references to .tag.html files
echo ' |-- updating require statements for tags' | tee -a package.log
sed -i.bak 's/\.tag\.html/\.tag/g' dist/src/tags/**/index{.d.ts,.js}
sed -i.bak 's/\.png/\.datauri/g' dist/src/tags/**/*.js
# add riot to tag files
echo ' `-- adding riot import to tags' | tee -a package.log
for i in dist/src/tags/**/*.tag.js; do
sed -i.bak $'1s/^/var riot = require("riot");\\\n/' $i
done
# -- IMAGES --
echo '== processing images' | tee -a package.log
# copy images
echo ' |-- copying images' | tee -a package.log
rsync -Rv src/tags/**/*.png dist >> package.log
echo ' `-- converting images to data uris' | tee -a package.log
for i in dist/src/tags/**/*.png; do
echo "data:$(file -bi "$i");base64,$(base64 "$i")" > ${i%.*}.datauri
done
echo '== cleaning up ==' | tee -a package.log
rm -rf dist/src/tags/**/*.png dist/src/tags/**/*.bak dist/src/tags/*.bak