forked from parallax/jsPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
45 lines (40 loc) · 1.26 KB
/
build.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
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
#
# Build script for jsPDF
# (c) 2014 Diego Casorran
#
# NOTE: Still relying on wak's wscript.py
# to generate dist/jspdf.source.js
#
# WARNING: I'm Ugly. Improve me, please.
#
output=dist/jspdf.min.js
options="-m -c --wrap --stats"
libs="`find libs/* -maxdepth 2 -type f | grep .js$ | grep -v -E '(\.min|BlobBuilder\.js$|Downloadify|demo|deps|test)'`"
files="jspdf.js jspdf.plugin*js"
commit=`git rev-parse HEAD`
build=`date +%Y-%m-%dT%H:%M`
# Update submodules
git submodule foreach git pull origin master
# Build dist files
wak.py && uglifyjs ${options} -o ${output} ${libs} ${files}
# Pretend license information to minimized file
for fn in ${files} ${libs}; do
awk '/^\/\*/,/\*\//' $fn \
| sed -n -e '1,/\*\//p' \
| sed -e 'H;${x;s/\s*@preserve/ /g;p;};d' \
| sed -e 's/\s*===\+//' \
| grep -v *global > ${output}.x
if test "x$fn" = "xjspdf.js"; then
cat ${output}.x \
| sed s/\${buildDate}/${build}/ \
| sed s/\${commitID}/${commit}/ >> ${output}.tmp
else
cat ${output}.x \
| sed -e '/Permission/,/SOFTWARE\./c \ ' \
| sed -E '/^\s\*\s*$/d' >> ${output}.tmp
fi
done
cat ${output} >> ${output}.tmp
cat ${output}.tmp | sed '/^\s*$/d' | sed "s/\"1\.0\.0-trunk\"/\"1.0.0-trunk ${build}\"/" > ${output}
rm -f ${output}.tmp ${output}.x