commit
7a4817e55a
|
@ -95,11 +95,12 @@ module Jekyll
|
||||||
# Private: Creates a regular expression from the config's keep_files array
|
# Private: Creates a regular expression from the config's keep_files array
|
||||||
#
|
#
|
||||||
# Examples
|
# Examples
|
||||||
# ['.git','.svn'] creates the following regex: /\/(\.git|\/.svn)/
|
# ['.git','.svn'] with site.dest "/myblog/_site" creates
|
||||||
|
# the following regex: /\A\/myblog\/_site\/(\.git|\/.svn)/
|
||||||
#
|
#
|
||||||
# Returns the regular expression
|
# Returns the regular expression
|
||||||
def keep_file_regex
|
def keep_file_regex
|
||||||
Regexp.union(site.keep_files)
|
/\A#{Regexp.quote(site.dest)}\/(#{Regexp.union(site.keep_files).source})/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,40 @@ class TestCleaner < JekyllUnitTest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "not-nested directory in keep_files and similary named directory not in keep_files" do
|
||||||
|
setup do
|
||||||
|
clear_dest
|
||||||
|
|
||||||
|
FileUtils.mkdir_p(dest_dir('.git/child_dir'))
|
||||||
|
FileUtils.mkdir_p(dest_dir('username.github.io'))
|
||||||
|
FileUtils.touch(File.join(dest_dir('.git'), 'index.html'))
|
||||||
|
FileUtils.touch(File.join(dest_dir('username.github.io'), 'index.html'))
|
||||||
|
|
||||||
|
@site = fixture_site
|
||||||
|
@site.keep_files = ['.git']
|
||||||
|
|
||||||
|
@cleaner = Cleaner.new(@site)
|
||||||
|
@cleaner.cleanup!
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
FileUtils.rm_rf(dest_dir('.git'))
|
||||||
|
FileUtils.rm_rf(dest_dir('username.github.io'))
|
||||||
|
end
|
||||||
|
|
||||||
|
should "keep the file in the directory in keep_files" do
|
||||||
|
assert File.exist?(File.join(dest_dir('.git'), 'index.html'))
|
||||||
|
end
|
||||||
|
|
||||||
|
should "delete the file in the directory not in keep_files" do
|
||||||
|
assert !File.exist?(File.join(dest_dir('username.github.io'), 'index.html'))
|
||||||
|
end
|
||||||
|
|
||||||
|
should "delete the directory not in keep_files" do
|
||||||
|
assert !File.exist?(dest_dir('username.github.io'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "directory containing no files and non-empty directories" do
|
context "directory containing no files and non-empty directories" do
|
||||||
setup do
|
setup do
|
||||||
clear_dest
|
clear_dest
|
||||||
|
|
Loading…
Reference in New Issue