Replace all_files_under with method that doesn't modify in-place
This commit is contained in:
parent
2ef3b7e4d9
commit
64878bfc23
|
@ -136,13 +136,15 @@ module Middleman
|
||||||
# @param paths Some paths string or Pathname
|
# @param paths Some paths string or Pathname
|
||||||
# @return [Array] An array of filenames
|
# @return [Array] An array of filenames
|
||||||
def self.all_files_under(*paths)
|
def self.all_files_under(*paths)
|
||||||
paths.flatten!
|
# when we drop 1.8, replace this with flat_map
|
||||||
paths.map! { |p| Pathname(p) }
|
paths.map do |p|
|
||||||
files = paths.select { |p| p.file? }
|
path = Pathname(p)
|
||||||
paths.select {|p| p.directory? }.each do |dir|
|
if path.directory?
|
||||||
files << all_files_under(dir.children)
|
all_files_under(*path.children)
|
||||||
end
|
elsif path.file?
|
||||||
files.flatten
|
path
|
||||||
|
end
|
||||||
|
end.flatten.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
# Simple shared cache implementation
|
# Simple shared cache implementation
|
||||||
|
|
Loading…
Reference in a new issue