-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompile-js.sh
executable file
·92 lines (76 loc) · 1.79 KB
/
compile-js.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
#@usage
#compile-js $command $output $input
#compile-js build ../html/assets/js/build/xylo.app.min.js *
#compile-js list manifest.txt
#compile-js build ../html/assets/js/build/xylo.app.min.js manifest.txt
#compile-js rebuild ../html/assets/js/build/xylo.app.min.js manifest.txt
#compile-js build ../html/assets/js/build/xylo.app.min.js booter.js xylo.js service.js
command=$1
output=$2
files=''
list=''
stale=false
compiler=~/Sites/libs/closure/compiler.jar
if test -z "$command"
then
echo "Please specify a command."
fi
if [ "$command" == "list" ]
then
for f in $3*.js
do
list=$list$f'\n'
echo -e "$f"
done
echo -e $list > $output
fi
if [ "$command" == "rebuild" ]
then
command="build"
stale=true
fi
if [ "$command" == "build" ]
then
for f in "$@"
do
if [ "$f" != "$1" ] && [ "$f" != "$2" ] && [[ $f == *.du ]] && [[ $f != *"#"* ]]
then
# echo $f
files=$files$f' '
fi
done
if test -z "$files"
then
files=`cat $3`
if test $3 -nt $output
then
echo $3' is newer then '$output
stale=true
fi
fi
for f in $files ; do
# skip commented lines
if [[ $f != "#"* ]]
then
list=$list'--js '$f' '
if test $f -nt $output
then
echo $f' is newer then '$output
stale=true
fi
fi
done
#echo -e $files
# closure help
# java -jar compiler.jar -h
# --compilation_level WHITESPACE_ONLY SIMPLE_OPTIMIZATIONS ADVANCED_OPTIMIZATIONS
# --externs ../src/js/angular/angular.min.js ../src/js/angular/angular-resource.min.js
if $stale ; then
echo "Compiling $output: "
java -jar $compiler $list --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file $output --warning_level QUIET --summary_detail_level 3
echo "completed $output."
else
echo "No new files to compile."
fi
fi