Merge pull request #487 from rstacruz/listener_fix
Fix the listener/watcher
This commit is contained in:
commit
f3f508399c
|
@ -33,13 +33,17 @@ module Middleman
|
||||||
|
|
||||||
mount_instance(app)
|
mount_instance(app)
|
||||||
|
|
||||||
|
start_file_watcher unless options[:"disable-watcher"]
|
||||||
|
|
||||||
@initialized ||= false
|
@initialized ||= false
|
||||||
unless @initialized
|
unless @initialized
|
||||||
@initialized = true
|
@initialized = true
|
||||||
|
|
||||||
register_signal_handlers unless ::Middleman::WINDOWS
|
register_signal_handlers unless ::Middleman::WINDOWS
|
||||||
|
|
||||||
start_file_watcher unless options[:"disable-watcher"]
|
# Save the last-used options so it may be re-used when
|
||||||
|
# reloading later on.
|
||||||
|
@last_options = options
|
||||||
|
|
||||||
@webrick.start
|
@webrick.start
|
||||||
end
|
end
|
||||||
|
@ -56,7 +60,7 @@ module Middleman
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def reload
|
def reload
|
||||||
stop
|
stop
|
||||||
start
|
start @last_options
|
||||||
end
|
end
|
||||||
|
|
||||||
# Stop the current instance, exit Webrick
|
# Stop the current instance, exit Webrick
|
||||||
|
@ -79,7 +83,10 @@ module Middleman
|
||||||
|
|
||||||
if added_and_modified.length > 0
|
if added_and_modified.length > 0
|
||||||
# See if the changed file is config.rb or lib/*.rb
|
# See if the changed file is config.rb or lib/*.rb
|
||||||
return reload if needs_to_reload?(added_and_modified)
|
if needs_to_reload?(added_and_modified)
|
||||||
|
reload
|
||||||
|
return listener.stop
|
||||||
|
end
|
||||||
|
|
||||||
# Otherwise forward to Middleman
|
# Otherwise forward to Middleman
|
||||||
added_and_modified.each do |path|
|
added_and_modified.each do |path|
|
||||||
|
@ -89,7 +96,10 @@ module Middleman
|
||||||
|
|
||||||
if removed.length > 0
|
if removed.length > 0
|
||||||
# See if the changed file is config.rb or lib/*.rb
|
# See if the changed file is config.rb or lib/*.rb
|
||||||
return reload if needs_to_reload?(removed)
|
if needs_to_reload?(removed)
|
||||||
|
reload
|
||||||
|
return listener.stop
|
||||||
|
end
|
||||||
|
|
||||||
# Otherwise forward to Middleman
|
# Otherwise forward to Middleman
|
||||||
removed.each do |path|
|
removed.each do |path|
|
||||||
|
|
Loading…
Reference in a new issue