Guest User

Untitled

a guest
May 26th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. #this script assumes you use jammit (jammit.documentcloud.com) to bundle and compress all of your javascripts
  4.  
  5. require 'yaml'
  6. require 'rubygems'
  7. require 'tempfile'
  8.  
  9. verbose = ARGV.include?("-v")
  10.  
  11. config = YAML::load(IO.read(File.dirname(__FILE__) + '/config/assets.yml'))
  12. common = config['javascripts']['common']
  13. tempfile = Tempfile.new("closure_output.js").path
  14. config['javascripts'].each do |group, filenames|
  15. puts "compiling #{group}" if verbose
  16. 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"
  17. output = `#{command}`
  18.  
  19. # the "X error(s), Y warning(s)" line will always be at the end
  20. puts results = output.grep(/\d+ warning\(s\)/).to_s if verbose
  21.  
  22. puts output
  23.  
  24. end
Add Comment
Please, Sign In to add comment