Trying to return from a block is a bad idea
This commit is contained in:
parent
06578c61fa
commit
77be952d41
3 changed files with 18 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
||||||
Master
|
Master
|
||||||
===
|
===
|
||||||
|
|
||||||
3.0.3
|
3.0.3-3.0.4
|
||||||
====
|
====
|
||||||
* Add reload_paths to server CLI to add additional paths to reload MM on change.
|
* Add reload_paths to server CLI to add additional paths to reload MM on change.
|
||||||
* Re-organize app reloading code, don't need to restart listen every time.
|
* Re-organize app reloading code, don't need to restart listen every time.
|
||||||
|
|
|
@ -223,7 +223,7 @@ module Middleman
|
||||||
# messages, which can take a long time (minutes at full CPU)
|
# messages, which can take a long time (minutes at full CPU)
|
||||||
# if the object is huge or has cyclic references, like this.
|
# if the object is huge or has cyclic references, like this.
|
||||||
def to_s
|
def to_s
|
||||||
"#<Middleman::Application>"
|
"#<Middleman::Application:0x#{object_id}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Expand a path to include the index file if it's a directory
|
# Expand a path to include the index file if it's a directory
|
||||||
|
|
|
@ -21,8 +21,6 @@ module Middleman
|
||||||
mount_instance
|
mount_instance
|
||||||
logger.info "== The Middleman is standing watch on port #{port}"
|
logger.info "== The Middleman is standing watch on port #{port}"
|
||||||
|
|
||||||
start_file_watcher unless @options[:"disable-watcher"]
|
|
||||||
|
|
||||||
@initialized ||= false
|
@initialized ||= false
|
||||||
unless @initialized
|
unless @initialized
|
||||||
@initialized = true
|
@initialized = true
|
||||||
|
@ -79,37 +77,27 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_file_watcher
|
def start_file_watcher
|
||||||
|
return if @options[:"disable-watcher"]
|
||||||
|
|
||||||
|
first_run = !@listener
|
||||||
|
|
||||||
|
if first_run
|
||||||
# Watcher Library
|
# Watcher Library
|
||||||
require "listen"
|
require "listen"
|
||||||
|
|
||||||
return if @listener
|
|
||||||
|
|
||||||
@listener = Listen.to(Dir.pwd, :relative_paths => true)
|
@listener = Listen.to(Dir.pwd, :relative_paths => true)
|
||||||
|
end
|
||||||
|
|
||||||
@listener.change do |modified, added, removed|
|
@listener.change do |modified, added, removed|
|
||||||
added_and_modified = (modified + added)
|
added_and_modified = (modified + added)
|
||||||
|
|
||||||
unless added_and_modified.empty?
|
|
||||||
# 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)
|
if needs_to_reload?(added_and_modified) || needs_to_reload?(removed)
|
||||||
reload
|
reload
|
||||||
return
|
else
|
||||||
end
|
|
||||||
|
|
||||||
# Otherwise forward to Middleman
|
|
||||||
added_and_modified.each do |path|
|
added_and_modified.each do |path|
|
||||||
app.files.did_change(path)
|
app.files.did_change(path)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
unless removed.empty?
|
|
||||||
# See if the changed file is config.rb or lib/*.rb
|
|
||||||
if needs_to_reload?(removed)
|
|
||||||
reload
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
# Otherwise forward to Middleman
|
|
||||||
removed.each do |path|
|
removed.each do |path|
|
||||||
app.files.did_delete(path)
|
app.files.did_delete(path)
|
||||||
end
|
end
|
||||||
|
@ -117,7 +105,7 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
# Don't block this thread
|
# Don't block this thread
|
||||||
@listener.start(false)
|
@listener.start(false) if first_run
|
||||||
end
|
end
|
||||||
|
|
||||||
# Trap the interupt signal and shut down smoothly
|
# Trap the interupt signal and shut down smoothly
|
||||||
|
@ -164,6 +152,7 @@ module Middleman
|
||||||
)
|
)
|
||||||
|
|
||||||
@app = new_app
|
@app = new_app
|
||||||
|
start_file_watcher
|
||||||
|
|
||||||
@webrick.mount "/", ::Rack::Handler::WEBrick, app.class.to_rack_app
|
@webrick.mount "/", ::Rack::Handler::WEBrick, app.class.to_rack_app
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue