Fixes #1860
This commit is contained in:
parent
3cbd9fdede
commit
49da6156a0
|
@ -1,3 +1,5 @@
|
||||||
|
require 'set'
|
||||||
|
|
||||||
module Middleman
|
module Middleman
|
||||||
module Util
|
module Util
|
||||||
include Contracts
|
include Contracts
|
||||||
|
@ -52,9 +54,15 @@ module Middleman
|
||||||
result.encode('UTF-8', 'UTF-8-MAC')
|
result.encode('UTF-8', 'UTF-8-MAC')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Contract String => Bool
|
||||||
|
def tilt_recognizes?(path)
|
||||||
|
@@tilt_lookup_cache ||= {}
|
||||||
|
@@tilt_lookup_cache[path] ||= ::Tilt[path]
|
||||||
|
end
|
||||||
|
|
||||||
Contract String => String
|
Contract String => String
|
||||||
def step_through_extensions(path)
|
def step_through_extensions(path)
|
||||||
while ::Tilt[path]
|
while tilt_recognizes?(path)
|
||||||
ext = ::File.extname(path)
|
ext = ::File.extname(path)
|
||||||
yield ext if block_given?
|
yield ext if block_given?
|
||||||
|
|
||||||
|
@ -80,14 +88,19 @@ module Middleman
|
||||||
# @return [String]
|
# @return [String]
|
||||||
Contract String => ArrayOf[String]
|
Contract String => ArrayOf[String]
|
||||||
def collect_extensions(path)
|
def collect_extensions(path)
|
||||||
return [] if ::File.basename(path).start_with?('.')
|
@@extensions_cache ||= {}
|
||||||
|
|
||||||
|
base_name = ::File.basename(path)
|
||||||
|
@@extensions_cache[base_name] ||= begin
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
step_through_extensions(path) { |e| result << e }
|
unless base_name.start_with?('.')
|
||||||
|
step_through_extensions(base_name) { |e| result << e }
|
||||||
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Finds files which should also be considered to be dirty when
|
# Finds files which should also be considered to be dirty when
|
||||||
# the given file(s) are touched.
|
# the given file(s) are touched.
|
||||||
|
@ -99,8 +112,9 @@ module Middleman
|
||||||
def find_related_files(app, files)
|
def find_related_files(app, files)
|
||||||
return [] if files.empty?
|
return [] if files.empty?
|
||||||
|
|
||||||
all_extensions = files.flat_map { |f| collect_extensions(f.to_s) }
|
file_set = ::Set.new(files)
|
||||||
|
|
||||||
|
all_extensions = files.flat_map { |f| collect_extensions(f.to_s) }
|
||||||
sass_type_aliasing = ['.scss', '.sass']
|
sass_type_aliasing = ['.scss', '.sass']
|
||||||
erb_type_aliasing = ['.erb', '.haml', '.slim']
|
erb_type_aliasing = ['.erb', '.haml', '.slim']
|
||||||
|
|
||||||
|
@ -109,14 +123,18 @@ module Middleman
|
||||||
|
|
||||||
all_extensions.uniq!
|
all_extensions.uniq!
|
||||||
|
|
||||||
app.sitemap.resources.select(&:file_descriptor).select { |r|
|
app.sitemap.resources.select { |r|
|
||||||
|
if r.file_descriptor
|
||||||
local_extensions = collect_extensions(r.file_descriptor[:full_path].to_s)
|
local_extensions = collect_extensions(r.file_descriptor[:full_path].to_s)
|
||||||
local_extensions |= sass_type_aliasing unless (local_extensions & sass_type_aliasing).empty?
|
local_extensions |= sass_type_aliasing unless (local_extensions & sass_type_aliasing).empty?
|
||||||
local_extensions |= erb_type_aliasing unless (local_extensions & erb_type_aliasing).empty?
|
local_extensions |= erb_type_aliasing unless (local_extensions & erb_type_aliasing).empty?
|
||||||
|
|
||||||
local_extensions.uniq!
|
local_extensions.uniq!
|
||||||
|
|
||||||
!(all_extensions & local_extensions).empty? && files.none? { |f| f == r.file_descriptor[:full_path] }
|
!(all_extensions & local_extensions).empty? && !file_set.include?(r.file_descriptor[:full_path])
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
}.map(&:file_descriptor)
|
}.map(&:file_descriptor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Middleman
|
module Middleman
|
||||||
# Current Version
|
# Current Version
|
||||||
# @return [String]
|
# @return [String]
|
||||||
VERSION = '4.1.4'.freeze unless const_defined?(:VERSION)
|
VERSION = '4.1.5'.freeze unless const_defined?(:VERSION)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue