Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 49 lines (42 sloc) 1.31 kb
bc9c026 @thomascube Add shellscripts to shrink/unshrink javascript files (by trisk)
thomascube authored
1 #!/bin/sh
2 JS_DIR=`dirname "$0"`/../program/js
54f1af8 @thomascube Download closure compiler to /tmp instead of current dir
thomascube authored
3 JAR_DIR='/tmp'
bc9c026 @thomascube Add shellscripts to shrink/unshrink javascript files (by trisk)
thomascube authored
4 CLOSURE_COMPILER_URL='http://closure-compiler.googlecode.com/files/compiler-latest.zip'
5
6 do_shrink() {
7 rm -f "$2"
54f1af8 @thomascube Download closure compiler to /tmp instead of current dir
thomascube authored
8 java -jar $JAR_DIR/compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js="$1" --js_output_file="$2"
bc9c026 @thomascube Add shellscripts to shrink/unshrink javascript files (by trisk)
thomascube authored
9 }
10
11 if [ ! -d "$JS_DIR" ]; then
12 echo "Directory $JS_DIR not found."
13 exit 1
14 fi
15
54f1af8 @thomascube Download closure compiler to /tmp instead of current dir
thomascube authored
16 if [ ! -w "$JAR_DIR" ]; then
17 JAR_DIR=`dirname "$0"`
18 fi
19
bc9c026 @thomascube Add shellscripts to shrink/unshrink javascript files (by trisk)
thomascube authored
20 if java -version >/dev/null 2>&1; then
21 :
22 else
23 echo "Java not found. Please ensure that the 'java' program is in your PATH."
24 exit 1
25 fi
26
54f1af8 @thomascube Download closure compiler to /tmp instead of current dir
thomascube authored
27 if [ ! -r "$JAR_DIR/compiler.jar" ]; then
bc9c026 @thomascube Add shellscripts to shrink/unshrink javascript files (by trisk)
thomascube authored
28 if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
29 wget "$CLOSURE_COMPILER_URL" -O "/tmp/$$.zip"
30 elif which curl >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
31 curl "$CLOSURE_COMPILER_URL" -o "/tmp/$$.zip"
32 else
54f1af8 @thomascube Download closure compiler to /tmp instead of current dir
thomascube authored
33 echo "Please download $CLOSURE_COMPILER_URL and extract compiler.jar to $JAR_DIR/."
bc9c026 @thomascube Add shellscripts to shrink/unshrink javascript files (by trisk)
thomascube authored
34 exit 1
35 fi
54f1af8 @thomascube Download closure compiler to /tmp instead of current dir
thomascube authored
36 (cd $JAR_DIR && unzip "/tmp/$$.zip" "compiler.jar")
bc9c026 @thomascube Add shellscripts to shrink/unshrink javascript files (by trisk)
thomascube authored
37 rm -f "/tmp/$$.zip"
38 fi
39
40 for fn in app common googiespell list; do
41 if [ -r "$JS_DIR/${fn}.js.src" ]; then
42 echo "$JS_DIR/${fn}.js.src already exists, not overwriting"
43 else
44 mv "$JS_DIR/${fn}.js" "$JS_DIR/${fn}.js.src"
45 fi
46 echo "Shrinking $JS_DIR/${fn}.js"
47 do_shrink "$JS_DIR/${fn}.js.src" "$JS_DIR/${fn}.js"
48 done
Something went wrong with that request. Please try again.