Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add an option for direct output in JS

  • Loading branch information...
commit 458a10b2e549ceec9f9f5e26d733f94874048290 1 parent 6a9df78
Damian Le Nouaille damln authored
6 README.md
Source Rendered
@@ -162,7 +162,7 @@ There following options can be passed to Guard::CoffeeScript:
162 162
163 163 ```ruby
164 164 :input => 'coffeescripts' # Relative path to the input directory.
165   - # A suffix `/(.+\.coffee)` will be added to this option.
  165 + # A suffix /(.+\.coffee) will be added to this option.
166 166 # default: nil
167 167
168 168 :output => 'javascripts' # Relative path to the output directory.
@@ -183,6 +183,10 @@ There following options can be passed to Guard::CoffeeScript:
183 183
184 184 :all_on_start => true # Regenerate all files on startup
185 185 # default: false
  186 +
  187 +:error_to_js => true # Print the Coffeescript error message directly in the
  188 + # JavaScript file
  189 + # default: false
186 190 ```
187 191
188 192 ### Output short notation
1  lib/guard/coffeescript.rb
@@ -18,6 +18,7 @@ class CoffeeScript < Guard
18 18 :shallow => false,
19 19 :hide_success => false,
20 20 :noop => false,
  21 + :error_to_js => false,
21 22 :all_on_start => false
22 23 }
23 24
8 lib/guard/coffeescript/runner.rb
@@ -60,6 +60,14 @@ def compile_files(files, watchers, options)
60 60 changed_files << write_javascript_file(content, file, directory, options)
61 61 rescue => e
62 62 error_message = file + ': ' + e.message.to_s
  63 +
  64 + if options[:error_to_js]
  65 + js_error_message = %q(#{error_message})
  66 + js_error_message = "var message = \"#{error_message} \";"
  67 + js_error_message += "throw message;"
  68 + changed_files << write_javascript_file(js_error_message, file, directory, options)
  69 + end
  70 +
63 71 errors << error_message
64 72 Formatter.error(error_message)
65 73 end

0 comments on commit 458a10b

Please sign in to comment.
Something went wrong with that request. Please try again.