Skip to content

Commit

Permalink
Merge pull request #272 from ddfreyne/bug-move-files-out-of-content
Browse files Browse the repository at this point in the history
Do not move files out of `content/` (fixes #271)
  • Loading branch information
bobthecow committed Mar 3, 2013
2 parents 238a378 + 9f8e24d commit 6560880
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nanoc/base/result_data/item_rep.rb
Expand Up @@ -143,7 +143,7 @@ def write(snapshot=:last)
is_modified = is_created || !FileUtils.identical?(raw_path, temp_path)

# Write
FileUtils.mv(temp_path, raw_path) if is_modified
FileUtils.cp(temp_path, raw_path) if is_modified

# Notify
Nanoc::NotificationCenter.post(:rep_written, self, raw_path, is_created, is_modified)
Expand Down
23 changes: 23 additions & 0 deletions test/base/test_compiler.rb
Expand Up @@ -519,4 +519,27 @@ def test_rep_assigns
end
end

def test_unfiltered_binary_item_should_not_be_moved_outside_content
with_site do
File.open('content/blah.dat', 'w') { |io| io.write('o hello') }

File.open('Rules', 'w') do |io|
io.write "compile '*' do\n"
io.write "end\n"
io.write "\n"
io.write "route '*' do\n"
io.write " item.identifier.chop + '.' + item[:extension]\n"
io.write "end\n"
io.write "\n"
io.write "layout '*', :erb\n"
end

site = Nanoc::Site.new('.')
site.compile

assert_equal Set.new(%w( content/blah.dat )), Set.new(Dir['content/*'])
assert_equal Set.new(%w( output/blah.dat )), Set.new(Dir['output/*'])
end
end

end

0 comments on commit 6560880

Please sign in to comment.