Skip to content

Commit

Permalink
Preserve the _bridgetown default value in keep_files config (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite authored Dec 14, 2024
1 parent 7f48f7e commit b6a636b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
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

0 comments on commit b6a636b

Please sign in to comment.