Read explicitly included dot-files in collections. #6091 (#6092)

Merge pull request 6092
This commit is contained in:
Anatoliy Yastreb 2017-06-15 04:42:43 +09:00 committed by jekyllbot
parent 4e3b5ba5b4
commit 2ceff6ab3e
5 changed files with 34 additions and 2 deletions

View File

@ -72,7 +72,7 @@ module Jekyll
def entries
return [] unless exists?
@entries ||=
Utils.safe_glob(collection_dir, ["**", "*"]).map do |entry|
Utils.safe_glob(collection_dir, ["**", "*"], File::FNM_DOTMATCH).map do |entry|
entry["#{collection_dir}/"] = ""
entry
end

View File

@ -36,7 +36,8 @@ module Jekyll
end
def included?(entry)
glob_include?(site.include, entry)
glob_include?(site.include, entry) ||
glob_include?(site.include, File.basename(entry))
end
def special?(entry)

View File

@ -0,0 +1 @@
I should be copied

View File

@ -0,0 +1 @@
I should be copied

View File

@ -222,4 +222,33 @@ class TestCollections < JekyllUnitTest
)
end
end
context "a collection with included dotfiles" do
setup do
@site = fixture_site({
"collections" => {
"methods" => {
"permalink" => "/awesome/:path/",
},
},
"include" => %w(.htaccess .gitignore),
})
@site.process
@collection = @site.collections["methods"]
end
should "contain .htaccess file" do
assert(@collection.files.any? { |d| d.name == ".htaccess" })
end
should "contain .gitignore file" do
assert(@collection.files.any? { |d| d.name == ".gitignore" })
end
should "have custom URL in static file" do
assert(
@collection.files.any? { |d| d.url.include?("/awesome/with.dots/") }
)
end
end
end