Adding support for closure compiler and some documentation
in the README about how to use it. git-svn-id: http://svn.openlayers.org/trunk/openlayers@11448 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
21
tools/closure.py
Normal file
21
tools/closure.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import sys
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
path = os.path.join(os.path.dirname(__file__), "closure-compiler.jar")
|
||||
if not os.path.exists(path):
|
||||
raise Exception("No closure-compiler.jar at %s; read README.txt!" % path)
|
||||
|
||||
def minimize(code):
|
||||
ntf = tempfile.NamedTemporaryFile()
|
||||
ntf.write(code)
|
||||
ntf.flush()
|
||||
|
||||
ntf2 = tempfile.NamedTemporaryFile()
|
||||
|
||||
os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name))
|
||||
ntf2.seek(0)
|
||||
data = ntf2.read()
|
||||
ntf.close()
|
||||
ntf2.close()
|
||||
return data
|
||||
Reference in New Issue
Block a user