Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve the _bridgetown default value in keep_files config #945

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions bridgetown-core/lib/bridgetown-core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def from(user_config, starting_defaults = DEFAULTS)
.setup_load_paths!
.setup_locales
.add_default_collections
.add_default_excludes
.add_destination_paths
.check_include_exclude
end
end
Expand All @@ -148,11 +148,15 @@ def run_initializers!(context:) # rubocop:todo Metrics/AbcSize, Metrics/Cyclomat
dsl._run_builtins!
self.url = cached_url if cached_url # restore local development URL if need be

setup_load_paths! appending: true
setup_post_init!

self
end

def setup_post_init!
add_destination_paths.setup_load_paths! appending: true
end

# @return [Set<SourceManifest>]
def source_manifests
@source_manifests ||= Set.new
Expand Down Expand Up @@ -357,13 +361,18 @@ def add_default_collections # rubocop:todo all
vendor/bundle/ vendor/cache/ vendor/gems/ vendor/ruby/
).freeze

def add_default_excludes
def add_destination_paths
self["keep_files"] << "_bridgetown" unless
self["keep_files"].nil?.! && self["keep_files"].include?("_bridgetown")

return self if self["exclude"].nil?

self["exclude"].concat(DEFAULT_EXCLUDES).uniq!
self
end

alias_method :add_default_excludes, :add_destination_paths

def should_execute_inline_ruby?
ENV["BRIDGETOWN_RUBY_IN_FRONT_MATTER"] != "false" &&
self["ruby_in_front_matter"]
Expand Down
5 changes: 5 additions & 0 deletions bridgetown-core/test/test_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ class TestSite < BridgetownUnitTest
FileUtils.touch(dest_dir(".git/HEAD"))
FileUtils.touch(dest_dir(".svn/HEAD"))
FileUtils.touch(dest_dir(".hg/HEAD"))
FileUtils.mkdir(dest_dir("_bridgetown"))
FileUtils.touch(dest_dir("_bridgetown/static"))
end

teardown do
Expand All @@ -276,6 +278,7 @@ class TestSite < BridgetownUnitTest
FileUtils.rm_rf(dest_dir(".git"))
FileUtils.rm_rf(dest_dir(".svn"))
FileUtils.rm_rf(dest_dir(".hg"))
FileUtils.rm_rf(dest_dir("_bridgetown"))
end

should "remove orphaned files in destination" do
Expand All @@ -285,6 +288,7 @@ class TestSite < BridgetownUnitTest
refute_exist dest_dir("quux")
assert_exist dest_dir(".git")
assert_exist dest_dir(".git", "HEAD")
assert_exist dest_dir("_bridgetown", "static")
end

should "remove orphaned files in destination - keep_files .svn" do
Expand All @@ -299,6 +303,7 @@ class TestSite < BridgetownUnitTest
refute_exist dest_dir(".git", "HEAD")
assert_exist dest_dir(".svn")
assert_exist dest_dir(".svn", "HEAD")
assert_exist dest_dir("_bridgetown", "static")
end
end

Expand Down