forked from open-xml-templating/docxtemplater-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.bash
executable file
·61 lines (52 loc) · 1.46 KB
/
bin.bash
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
50
51
52
53
54
55
56
57
58
59
60
61
#/usr/bin/bash
set -e
set -u
npm install -g uglify-js browserify
uglifyversion="$(uglifyjs --version)"
echo "using : $uglifyversion"
[[ "$uglifyversion" =~ "3." ]] || { echo "you need version 3.x of uglifyjs"; exit 1; }
if [ ! -d src ]; then
git clone https://github.com/open-xml-templating/docxtemplater.git src
else
cd src
git checkout master
git pull
cd ..
fi
mkdir build -p
cd src
for tag in $(git tag | sort --version-sort)
do
cd ..
filename="$(pwd)""/build/docxtemplater.""$tag"".js"
minfilename="$(pwd)""/build/docxtemplater.""$tag"".min.js"
cd src
# Skipping versions < 1.0
echo "$tag" | grep "v[123]" || continue
# Skipping Already existing versions
if [ -f "$filename" ] && [ -f "$minfilename" ]; then echo "Skipping $tag (file exists)" && continue; fi
echo "processing $tag"
git checkout "$tag"
npm install
[ -f gulpfile.js ] && gulp allCoffee
npm test
result=$?
echo "result : $result"
cd ..
if [ "$result" == "0" ]; then
echo "running browserify"
startfilename="./src/js/docxgen.js"
[ -f "$startfilename" ] || startfilename="./src/js/docxtemplater.js"
browserify -r "$startfilename" -s Docxtemplater > "$filename"
echo "running uglify"
uglifyjs "$filename" > "$minfilename" --verbose --ascii-only
echo "runned uglify"
fi
# Copy latest tag to docxtemplater-latest.{min,}.js
cp "$filename" build/docxtemplater-latest.js
cp "$minfilename" build/docxtemplater-latest.min.js
git add .
git commit -am "$tag"
git tag "$tag"
cd src
done