Browse Source

Rakefile : add logic if compiler isn't there

pull/14/head
David DeSandro 14 years ago
parent
commit
72ebb02427
  1. 21
      Rakefile

21
Rakefile

@ -2,19 +2,22 @@
# requires Google Closure Compiler http://code.google.com/closure/compiler/ # requires Google Closure Compiler http://code.google.com/closure/compiler/
# from command line run: # from command line run:
# rake min COMPILER='path/to/compiler.jar' # rake min COMPILER='path/to/compiler.jar'
file compiler = ENV["COMPILER"] || '~/resources/google-closure/compiler.jar' file compiler = ENV["COMPILER"] || '../../resources/google-closure/compiler.jar'
js = 'jquery.isotope.js' js = 'jquery.isotope.js'
min_js = 'jquery.isotope.min.js' min_js = 'jquery.isotope.min.js'
desc "Generates #{min_js}" desc "Generates #{min_js}"
task :min do task :min do
puts "Minifying jquery.isotope.js..." unless File.exists?( compiler )
sh "java -jar #{compiler} --js #{js} --js_output_file #{min_js}" puts "ERROR: Compiler not found at " + compiler
# Adds header comment else
min = File.read( min_js ) puts "Minifying jquery.isotope.js..."
File.open( min_js, 'w') do |f| sh "java -jar #{compiler} --js #{js} --js_output_file #{min_js}"
f.write File.readlines( js )[0..9].join() # Adds header comment
f.write min min = File.read( min_js )
File.open( min_js, 'w') do |f|
f.write File.readlines( js )[0..9].join()
f.write min
end
end end
end end

Loading…
Cancel
Save