pretty-print coffeescript compile errors

This commit is contained in:
John Bintz 2011-05-09 07:35:50 -04:00
parent 086086cd3e
commit 58a952a4dd
2 changed files with 11 additions and 1 deletions

View File

@ -9,11 +9,13 @@ require 'getoptlong'
require 'rubygems'
gem 'rainbow'
gem 'jasmine'
gem 'coffee-script'
require 'jasmine'
require 'coffee-script'
require 'rainbow'
require 'jasmine/cli'
include Jasmine::CLI
@ -73,7 +75,14 @@ files = files.flatten.compact.collect { |file|
when '.js'
%{<script type="text/javascript" src="#{file}"></script>}
when '.coffee'
%{<script type="text/javascript">#{CoffeeScript.compile File.read(file)}</script>}
begin
%{<script type="text/javascript">#{CoffeeScript.compile(fh = File.open(file))}</script>}
rescue CoffeeScript::CompilationError => e
puts "[%s] %s: %s" % [ 'coffeescript'.color(:red), file.color(:yellow), e.message.color(:white) ]
exit 1
ensure
fh.close
end
when '.css'
%{<link rel="stylesheet" href="#{file}" type="text/css" />}
end

View File

@ -22,4 +22,5 @@ Gem::Specification.new do |s|
s.add_dependency 'jasmine'
s.add_dependency 'coffee-script'
s.add_dependency 'rainbow'
end