-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathbuilder
executable file
·67 lines (57 loc) · 1.45 KB
/
builder
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
62
63
64
65
66
67
#!/usr/bin/env bash
read -r -d '' USAGE << 'EOF'\
Builds augment.js, accepts the following switches:
-h : prints this message
-e : builds all methods except these ones
-o : builds only these methods
-m : whether to minify the output
Examples:
./builder : builds all methods
./builder -m : builds all methods and minifies
./builder -e map : builds all methods except map
./builder -e array -m : builds all methods except array methods and minifies
./builder -o string : builds only string methods
./builder -o "forEach map" -m : builds only forEach and map and minifies
EOF
while getopts "e:o:mh" OPTION
do
case "$OPTION" in
h) show_usage="1"
;;
e) except="$OPTARG"
;;
o) only="$OPTARG"
;;
m) minify="1"
;;
?) exit 2
;;
esac
done
if [[ $show_usage ]]; then
echo "$USAGE"
exit
fi
version=$(cat VERSION)
if [[ $except ]]; then
version=$version".custom"
shopt -s extglob
methods=`echo $except | sed -e 's/ /|/g'`
files="lib/!(*@($methods)*)"
else
if [[ $only ]]; then
version=$version".custom"
for method in $only
do
files=$files" lib/*$method*"
done
else
files=lib/augment*.js
fi
fi
if [[ $minify ]]; then
cat lib/header.js $files | sed "s/@VERSION/${version}/" | uglifyjs
else
cat lib/header.js $files | sed "s/@VERSION/${version}/"
fi
shopt -u extglob