Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add an option for direct output in JS

  • Loading branch information...
commit 458a10b2e549ceec9f9f5e26d733f94874048290 1 parent 6a9df78
Damian Le Nouaille damln authored
6 README.md
View
@@ -162,7 +162,7 @@ There following options can be passed to Guard::CoffeeScript:
```ruby
:input => 'coffeescripts' # Relative path to the input directory.
- # A suffix `/(.+\.coffee)` will be added to this option.
+ # A suffix /(.+\.coffee) will be added to this option.
# default: nil
:output => 'javascripts' # Relative path to the output directory.
@@ -183,6 +183,10 @@ There following options can be passed to Guard::CoffeeScript:
:all_on_start => true # Regenerate all files on startup
# default: false
+
+:error_to_js => true # Print the Coffeescript error message directly in the
+ # JavaScript file
+ # default: false
```
### Output short notation
1  lib/guard/coffeescript.rb
View
@@ -18,6 +18,7 @@ class CoffeeScript < Guard
:shallow => false,
:hide_success => false,
:noop => false,
+ :error_to_js => false,
:all_on_start => false
}
8 lib/guard/coffeescript/runner.rb
View
@@ -60,6 +60,14 @@ def compile_files(files, watchers, options)
changed_files << write_javascript_file(content, file, directory, options)
rescue => e
error_message = file + ': ' + e.message.to_s
+
+ if options[:error_to_js]
+ js_error_message = %q(#{error_message})
+ js_error_message = "var message = \"#{error_message} \";"
+ js_error_message += "throw message;"
+ changed_files << write_javascript_file(js_error_message, file, directory, options)
+ end
+
errors << error_message
Formatter.error(error_message)
end
Please sign in to comment.
Something went wrong with that request. Please try again.