Fix slow server boot. It was recursing through node_modules and .git on initial boot
This commit is contained in:
parent
8c27d9a2e7
commit
598d72480f
3 changed files with 15 additions and 8 deletions
|
@ -49,6 +49,8 @@ module Middleman
|
|||
# Reference to lower level listener
|
||||
attr_reader :listener
|
||||
|
||||
IGNORED_DIRECTORIES = %w(.git node_modules .sass-cache)
|
||||
|
||||
# Construct a new SourceWatcher
|
||||
#
|
||||
# @param [Middleman::Sources] parent The parent collection.
|
||||
|
@ -182,7 +184,7 @@ module Middleman
|
|||
|
||||
Contract ArrayOf[Pathname]
|
||||
def find_new_files!
|
||||
new_files = ::Middleman::Util.all_files_under(@directory.to_s)
|
||||
new_files = ::Middleman::Util.all_files_under(@directory.to_s, &method(:should_not_recurse?))
|
||||
.reject { |p| @files.key?(p) }
|
||||
|
||||
update(new_files, []).flatten.map { |s| s[:full_path] }
|
||||
|
@ -193,7 +195,7 @@ module Middleman
|
|||
# @return [void]
|
||||
Contract ArrayOf[Pathname]
|
||||
def poll_once!
|
||||
updated = ::Middleman::Util.all_files_under(@directory.to_s)
|
||||
updated = ::Middleman::Util.all_files_under(@directory.to_s, &method(:should_not_recurse?))
|
||||
removed = @files.keys.reject { |p| updated.include?(p) }
|
||||
|
||||
result = update(updated, removed)
|
||||
|
@ -217,6 +219,11 @@ module Middleman
|
|||
|
||||
protected
|
||||
|
||||
Contract Pathname => Bool
|
||||
def should_not_recurse?(p)
|
||||
IGNORED_DIRECTORIES.include?(p.basename.to_s)
|
||||
end
|
||||
|
||||
# The `listen` gem callback.
|
||||
#
|
||||
# @param [Array] modified List of modified files.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue