Reload MM on environment and helpers_dir changes. Closes #1274. Closes #1105

This commit is contained in:
Thomas Reynolds 2014-07-05 18:26:51 -07:00
parent c94470d33f
commit 13acee8fd5

View file

@ -127,7 +127,7 @@ module Middleman
# See if the changed file is config.rb or lib/*.rb # See if the changed file is config.rb or lib/*.rb
if needs_to_reload?(added_and_modified + removed) if needs_to_reload?(added_and_modified + removed)
@mm_reload = true $mm_reload = true
@webrick.stop @webrick.stop
else else
added_and_modified.each do |path| added_and_modified.each do |path|
@ -213,9 +213,10 @@ module Middleman
# @return [Boolean] Whether the server needs to reload # @return [Boolean] Whether the server needs to reload
def needs_to_reload?(paths) def needs_to_reload?(paths)
match_against = [ match_against = [
%r{^config\.rb}, %r{^/config\.rb},
%r{^lib/[^\.](.*)\.rb$}, %r{^/environments/[^\.](.*)\.rb$},
%r{^helpers/[^\.](.*)\.rb$} %r{^/lib/[^\.](.*)\.rb$},
%r{^/#{@app.config[:helpers_dir]}/[^\.](.*)\.rb$}
] ]
if @options[:reload_paths] if @options[:reload_paths]
@ -226,7 +227,7 @@ module Middleman
paths.any? do |path| paths.any? do |path|
match_against.any? do |matcher| match_against.any? do |matcher|
path =~ matcher path.sub(@app.root, '').match matcher
end end
end end
end end