move_new_block
Thomas Reynolds 2016-01-10 17:14:41 -08:00
parent 5cac6a1896
commit c6401f1cd9
4 changed files with 26 additions and 3 deletions

View File

@ -12,6 +12,7 @@ master
* Fix new extension template
* Don't parse frontmatter on ignored files.
* Fix displaying frontmatter on `/__middleman/sitemap`
* Add `skip_build_clean` config which when set to a block, will avoid removing non-generated paths from build, like .git #1716
# 4.0.0

View File

@ -16,6 +16,22 @@ Feature: Build Clean
| build/should_be_ignored3.html |
And the file "build/index.html" should contain "Comment in layout"
Scenario: Clean build has a whitelist
Given a fixture app "clean-app"
When a file named "build/.test" with:
"""
Hello
"""
When a file named "config.rb" with:
"""
set :skip_build_clean do |path|
path =~ /\.test/
end
"""
Given a built app at "clean-app"
Then the following files should exist:
| build/.test |
Scenario: Clean build an app with newly ignored files and a nested output directory
Given a fixture app "clean-nested-app"
When a file named "config.rb" with:

View File

@ -191,6 +191,8 @@ module Middleman
yaml: [%w(--- ---), %w(--- ...)]
}, 'Allowed frontmatter delimiters'
define_setting :skip_build_clean, proc { |p| [/\.git/].any? { |r| r.match(p) } }, 'Whether some paths should not be removed during a clean build.'
define_setting :watcher_disable, false, 'If the Listen watcher should not run'
define_setting :watcher_force_polling, false, 'If the Listen watcher should run in polling mode'
define_setting :watcher_latency, nil, 'The Listen watcher latency'

View File

@ -58,7 +58,7 @@ module Middleman
prerender_css
output_files
clean if @cleaning
clean! if @cleaning
::Middleman::Profiling.report('build')
@ -219,8 +219,12 @@ module Middleman
# Remove files which were not built in this cycle
Contract ArrayOf[Pathname]
def clean
@to_clean.each do |f|
def clean!
to_remove = @to_clean.reject do |f|
app.config[:skip_build_clean].call(f.to_s)
end
to_remove.each do |f|
FileUtils.rm(f)
trigger(:deleted, f)
end