Skip to content

Commit

Permalink
Remove deletion of dot files on cleanup.
Browse files Browse the repository at this point in the history
This is a potentially very dangerous action that's impossible to test that it's correct.
If the '..' check line ever disappears, even running the tests will start deleting
everything accessible on the person's computer.

All dot-files that are generated are already known by Jekyll as either a static file or
a page (yaml front matter), only remove those files.
  • Loading branch information
Jason Roelofs committed Apr 4, 2012
1 parent 4499df8 commit 8368485
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/jekyll/site.rb
Expand Up @@ -215,8 +215,8 @@ def render
def cleanup def cleanup
# all files and directories in destination, including hidden ones # all files and directories in destination, including hidden ones
dest_files = Set.new dest_files = Set.new
Dir.glob(File.join(self.dest, "**", "*"), File::FNM_DOTMATCH) do |file| Dir.glob(File.join(self.dest, "**", "*")) do |file|
dest_files << file unless file =~ /\/\.{1,2}$/ dest_files << file
end end


# files to be written # files to be written
Expand Down
4 changes: 0 additions & 4 deletions test/test_site.rb
Expand Up @@ -171,8 +171,6 @@ class TestSite < Test::Unit::TestCase
clear_dest clear_dest
@site.process @site.process
# generate some orphaned files: # generate some orphaned files:
# hidden file
File.open(dest_dir('.htpasswd'), 'w')
# single file # single file
File.open(dest_dir('obsolete.html'), 'w') File.open(dest_dir('obsolete.html'), 'w')
# single file in sub directory # single file in sub directory
Expand All @@ -183,15 +181,13 @@ class TestSite < Test::Unit::TestCase
end end


teardown do teardown do
FileUtils.rm_f(dest_dir('.htpasswd'))
FileUtils.rm_f(dest_dir('obsolete.html')) FileUtils.rm_f(dest_dir('obsolete.html'))
FileUtils.rm_rf(dest_dir('qux')) FileUtils.rm_rf(dest_dir('qux'))
FileUtils.rm_f(dest_dir('quux')) FileUtils.rm_f(dest_dir('quux'))
end end


should 'remove orphaned files in destination' do should 'remove orphaned files in destination' do
@site.process @site.process
assert !File.exist?(dest_dir('.htpasswd'))
assert !File.exist?(dest_dir('obsolete.html')) assert !File.exist?(dest_dir('obsolete.html'))
assert !File.exist?(dest_dir('qux')) assert !File.exist?(dest_dir('qux'))
assert !File.exist?(dest_dir('quux')) assert !File.exist?(dest_dir('quux'))
Expand Down

0 comments on commit 8368485

Please sign in to comment.