Skip to content

Commit

Permalink
Fix selective bare option. (Closes #24)
Browse files Browse the repository at this point in the history
  • Loading branch information
netzpirat committed Sep 9, 2013
1 parent 2c24129 commit be96810
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Master

- [#24](https://github.com/netzpirat/guard-coffeescript/issues/24) Fix selective `bare` option.

## 1.3.2 - Mai 30, 2013

- [#11](https://github.com/guard/guard-coffeescript/issues/11) Improve source map support. ([@jabbawookiees][])
Expand Down
3 changes: 2 additions & 1 deletion lib/guard/coffeescript/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def compile_files(files, watchers, options)
#
def compile(filename, options)
file = File.read(filename)
file_options = options_for_file(file, options)
file_options = options_for_file(filename, options)

if options[:source_map]
file_options.merge! options_for_source_map(filename, options)
result = ::CoffeeScript.compile(file, file_options)
Expand Down
12 changes: 4 additions & 8 deletions spec/guard/coffeescript/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,17 @@
before do
runner.unstub(:compile)
::CoffeeScript.stub(:compile)
File.stub(:read) { |file| file }
end

after do
runner.stub(:compile).and_return ''
::CoffeeScript.unstub(:compile)
File.should_receive(:read).with('src/a.coffee').and_return 'a = -> 1'
File.should_receive(:read).with('src/b.coffee').and_return 'b = -> 2'
end

it 'should compile files in the list without the outer function wrapper' do
::CoffeeScript.should_receive(:compile).with 'src/a.coffee', hash_including(:bare => true)
::CoffeeScript.should_receive(:compile).with 'a = -> 1', hash_including(:bare => true)
runner.run(['src/a.coffee', 'src/b.coffee'], [watcher], { :output => 'target', :bare => ['a.coffee'] })
end

it 'should compile files not in the list with the outer function wrapper' do
::CoffeeScript.should_receive(:compile).with 'src/b.coffee', hash_including(:bare => false)
::CoffeeScript.should_receive(:compile).with 'b = -> 2', hash_including(:bare => false)
runner.run(['src/a.coffee', 'src/b.coffee'], [watcher], { :output => 'target', :bare => ['a.coffee'] })
end
end
Expand Down

0 comments on commit be96810

Please sign in to comment.