25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.5KB

  1. require 'rake'
  2. require 'rake/clean'
  3. task :default => :test
  4. def minified_file
  5. ENV['FILE'] || 'mustache.min.js'
  6. end
  7. desc "Run all tests"
  8. task :test do
  9. sh "./node_modules/.bin/mocha test"
  10. end
  11. desc "Make a compressed build in #{minified_file}"
  12. task :minify do
  13. sh "./node_modules/.bin/uglifyjs mustache.js > #{minified_file}"
  14. end
  15. desc "Run JSHint"
  16. task :hint do
  17. sh "./node_modules/.bin/jshint mustache.js"
  18. end
  19. # Creates a task that uses the various template wrappers to make a wrapped
  20. # output file. There is some extra complexity because Dojo and YUI use
  21. # different final locations.
  22. def templated_build(name, final_location=nil)
  23. short = name.downcase
  24. source = File.join("wrappers", short)
  25. dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
  26. target_js = final_location.nil? ? "#{short}.mustache.js" : "mustache.js"
  27. desc "Package for #{name}"
  28. task short.to_sym => dependencies do
  29. puts "Packaging for #{name}"
  30. mkdir_p final_location unless final_location.nil?
  31. sources = [ "#{source}/mustache.js.pre", 'mustache.js', "#{source}/mustache.js.post" ]
  32. relative_name = "#{final_location || '.'}/#{target_js}"
  33. open(relative_name, 'w') do |f|
  34. sources.each {|source| f << File.read(source) }
  35. end
  36. puts "Done, see #{relative_name}"
  37. end
  38. CLEAN.include(final_location.nil? ? target_js : final_location)
  39. end
  40. templated_build "jQuery"
  41. templated_build "MooTools"
  42. templated_build "Dojo", "dojox/string"
  43. templated_build "YUI3", "yui3/mustache"
  44. templated_build "qooxdoo"