Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- #this script assumes you use jammit (jammit.documentcloud.com) to bundle and compress all of your javascripts
- require 'yaml'
- require 'rubygems'
- require 'tempfile'
- verbose = ARGV.include?("-v")
- config = YAML::load(IO.read(File.dirname(__FILE__) + '/config/assets.yml'))
- common = config['javascripts']['common']
- tempfile = Tempfile.new("closure_output.js").path
- config['javascripts'].each do |group, filenames|
- puts "compiling #{group}" if verbose
- command = "java -jar path/to/closure-compiler-20100201.jar #{verbose ? "--warning_level VERBOSE" : "--warning_level QUIET"} --js #{(filenames).join(" --js ")} --externs a_file_where_you_put_all_your_external_variables_like_$.js --js_output_file #{tempfile} 2>&1"
- output = `#{command}`
- # the "X error(s), Y warning(s)" line will always be at the end
- puts results = output.grep(/\d+ warning\(s\)/).to_s if verbose
- puts output
- end
Add Comment
Please, Sign In to add comment