Fix build --clean when paths are rerouted.
This was mostly apparent when using directory indexes - because the rewrite of the destination path happened after the point where the path was removed from the "to clean" list, directory indexes would get removed on the next build --clean.
This commit is contained in:
parent
46e6d37fff
commit
8648aaed7c
4 changed files with 19 additions and 6 deletions
|
@ -7,3 +7,9 @@ Feature: Build Clean
|
||||||
Then "should_be_ignored.html" should not exist at "clean-app"
|
Then "should_be_ignored.html" should not exist at "clean-app"
|
||||||
And "should_be_ignored2.html" should not exist at "clean-app"
|
And "should_be_ignored2.html" should not exist at "clean-app"
|
||||||
And "should_be_ignored3.html" should not exist at "clean-app"
|
And "should_be_ignored3.html" should not exist at "clean-app"
|
||||||
|
|
||||||
|
Scenario: Clean an app with directory indexes
|
||||||
|
Given a built app at "clean-dir-app"
|
||||||
|
Then "about/index.html" should exist at "clean-dir-app"
|
||||||
|
Given a built app at "clean-dir-app" with flags "--clean"
|
||||||
|
Then "about/index.html" should exist at "clean-dir-app"
|
||||||
|
|
2
fixtures/clean-dir-app/config.rb
Normal file
2
fixtures/clean-dir-app/config.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
activate :directory_indexes
|
1
fixtures/clean-dir-app/source/about.html
Normal file
1
fixtures/clean-dir-app/source/about.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fun times
|
|
@ -30,6 +30,8 @@ module Middleman
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
module ThorActions
|
module ThorActions
|
||||||
|
# Render a template to a file.
|
||||||
|
# @return [String] the actual destination file path that was created
|
||||||
def tilt_template(source, *args, &block)
|
def tilt_template(source, *args, &block)
|
||||||
config = args.last.is_a?(Hash) ? args.pop : {}
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
||||||
destination = args.first || source
|
destination = args.first || source
|
||||||
|
@ -41,6 +43,8 @@ module Middleman
|
||||||
|
|
||||||
response = ::Middleman::Builder.shared_rack.get(request_path.gsub(/\s/, "%20"))
|
response = ::Middleman::Builder.shared_rack.get(request_path.gsub(/\s/, "%20"))
|
||||||
create_file(destination, response.body, config) if response.status == 200
|
create_file(destination, response.body, config) if response.status == 200
|
||||||
|
|
||||||
|
destination
|
||||||
# rescue
|
# rescue
|
||||||
# say_status :error, destination, :red
|
# say_status :error, destination, :red
|
||||||
# end
|
# end
|
||||||
|
@ -130,7 +134,7 @@ module Middleman
|
||||||
def queue_current_paths
|
def queue_current_paths
|
||||||
@cleaning_queue = []
|
@cleaning_queue = []
|
||||||
Find.find(@destination) do |path|
|
Find.find(@destination) do |path|
|
||||||
next if path.match(/\/\./)
|
next if path.match(/\/\./) && !path.match(/\.htaccess/)
|
||||||
unless path == destination
|
unless path == destination
|
||||||
@cleaning_queue << path.sub(@destination, destination[/([^\/]+?)$/])
|
@cleaning_queue << path.sub(@destination, destination[/([^\/]+?)$/])
|
||||||
end
|
end
|
||||||
|
@ -163,13 +167,13 @@ module Middleman
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
@cleaning_queue.delete(file_destination) if cleaning?
|
|
||||||
|
|
||||||
if @config[:glob]
|
if @config[:glob]
|
||||||
next unless File.fnmatch(@config[:glob], file_source)
|
next unless File.fnmatch(@config[:glob], file_source)
|
||||||
end
|
end
|
||||||
|
|
||||||
base.tilt_template(file_source, file_destination, { :force => true })
|
file_destination = base.tilt_template(file_source, file_destination, { :force => true })
|
||||||
|
|
||||||
|
@cleaning_queue.delete(file_destination) if cleaning?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue