Created
August 15, 2011 02:11
-
-
Save fearofcode/1145600 to your computer and use it in GitHub Desktop.
Sample script to call google closure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dircache | |
import os | |
import os.path | |
import fnmatch | |
# change these as needed | |
js_dirs = ["js/", "js/lib/"] | |
output_file = "output.js" | |
jar_path = "lib/java/" | |
compilation_level = "ADVANCED_OPTIMIZATIONS" | |
# you generally shouldn't need to change any of this | |
js_ext = ".js" | |
def files(dir): | |
return filter(lambda f: f.endswith(js_ext), map(lambda f: dir + f, dircache.listdir(dir))) | |
def all_files(): | |
lists = map(files, js_dirs) | |
return [item for sublist in lists for item in sublist] | |
cmd_prefix = "java -jar " + jar_path + "compiler.jar" | |
file_list = all_files() | |
js_file_str = ' '.join(map(lambda f: "--js " + f, file_list)) | |
cmd = "%s --compilation_level %s %s --js_output_file %s" % (cmd_prefix, compilation_level, js_file_str, output_file) | |
print cmd | |
os.system(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment