Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix wrong output whitout :output option. (Fixes #12)

  • Loading branch information...
commit 1f5725e3dea3dd3545e3cd75e5ff02fad48b734d 1 parent a87d456
@netzpirat netzpirat authored
View
2  lib/guard/coffeescript/runner.rb
@@ -133,7 +133,7 @@ def detect_nested_directories(watchers, files, options)
watchers.product(files).each do |watcher, file|
if matches = file.match(watcher.pattern)
- target = matches[1] ? File.join(options[:output], File.dirname(matches[1])).gsub(/\/\.$/, '') : options[:output] || '.'
+ target = matches[1] ? File.join(options[:output], File.dirname(matches[1])).gsub(/\/\.$/, '') : options[:output] || File.dirname(file)
if directories[target]
directories[target] << file
else
View
14 spec/guard/coffeescript/runner_spec.rb
@@ -48,6 +48,20 @@
end
end
+ context 'without the :output option' do
+ it 'compiles the CoffeeScripts to the same dir like the file and replace .coffee with .js' do
+ FileUtils.should_receive(:mkdir_p).with("#{ @project_path }/src")
+ File.should_receive(:open).with("#{ @project_path }/src/a.js", 'w')
+ runner.run(['src/a.coffee'], [watcher])
+ end
+
+ it 'compiles the CoffeeScripts to the same dir like the file and replace .js.coffee with .js' do
+ FileUtils.should_receive(:mkdir_p).with("#{ @project_path }/src")
+ File.should_receive(:open).with("#{ @project_path }/src/a.js", 'w')
+ runner.run(['src/a.js.coffee'], [watcher])
+ end
+ end
+
context 'with the :noop option' do
it 'does not write the output file' do
FileUtils.should_not_receive(:mkdir_p).with("#{ @project_path }/target")
Please sign in to comment.
Something went wrong with that request. Please try again.