Merge pull request #1118 from maul-esel/dir-bug-take2
[bugfix #417] delete old files that have been replaced by a directory
This commit is contained in:
commit
2484833bc8
|
@ -117,3 +117,14 @@ Feature: Create sites
|
|||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
And I should see "SomeDirective" in "_site/.htaccess"
|
||||
|
||||
Scenario: File was replaced by a directory
|
||||
Given I have a "test" file that contains "some stuff"
|
||||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
When I delete the file "test"
|
||||
Given I have a test directory
|
||||
And I have a "test/index.html" file that contains "some other stuff"
|
||||
When I run jekyll
|
||||
Then the _site/test directory should exist
|
||||
And I should see "some other stuff" in "_site/test/index.html"
|
||||
|
|
|
@ -131,6 +131,10 @@ When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
|
|||
end
|
||||
end
|
||||
|
||||
When /^I delete the file "(.*)"$/ do |file|
|
||||
File.delete(file)
|
||||
end
|
||||
|
||||
Then /^the (.*) directory should exist$/ do |dir|
|
||||
assert File.directory?(dir), "The directory \"#{dir}\" does not exist"
|
||||
end
|
||||
|
|
|
@ -270,7 +270,11 @@ module Jekyll
|
|||
files.each { |file| dirs << File.dirname(file) }
|
||||
files.merge(dirs)
|
||||
|
||||
obsolete_files = dest_files - files
|
||||
# files that are replaced by dirs should be deleted
|
||||
files_to_delete = Set.new
|
||||
dirs.each { |dir| files_to_delete << dir if File.file?(dir) }
|
||||
|
||||
obsolete_files = dest_files - files + files_to_delete
|
||||
FileUtils.rm_rf(obsolete_files.to_a)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue