Skip to content

Commit

Permalink
Helpful error messages on rake tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
zmack committed Nov 24, 2010
1 parent 356664a commit a98ecc9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
require 'rubygems'
require 'closure-compiler'

HEADER = /((^\s*\/\/.*\n)+)/

desc "rebuild the backbone-min.js files for distribution"
task :build do
begin
require 'closure-compiler'
rescue LoadError
puts %{closure-compiler not found.\nInstall it by running 'gem install closure-compiler'}
exit
end
source = File.read 'backbone.js'
header = source.match(HEADER)
File.open('backbone-min.js', 'w+') do |file|
Expand All @@ -14,6 +19,8 @@ end

desc "build the docco documentation"
task :doc do
check('docco', 'docco', 'https://github.com/jashkenas/docco')

system [
'docco backbone.js',
'docco examples/todos/todos.js examples/backbone-localstorage.js'
Expand All @@ -27,5 +34,15 @@ end

desc "test the CoffeeScript integration"
task :test do
check('coffee', 'CoffeeScript', 'https://github.com/jashkenas/coffee-script.git')

system "coffee test/*.coffee"
end
end


def check(exec, name, url)
return unless `which #{exec}`.empty?

puts "#{name} not found.\nGet it from #{url}"
exit
end

0 comments on commit a98ecc9

Please sign in to comment.