commit
ba38498909
|
@ -111,18 +111,15 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_file_watcher
|
def start_file_watcher
|
||||||
return if @options[:disable_watcher]
|
return if @listener or @options[:disable_watcher]
|
||||||
|
|
||||||
first_run = !@listener
|
|
||||||
|
|
||||||
if first_run
|
|
||||||
# Watcher Library
|
# Watcher Library
|
||||||
require 'listen'
|
require 'listen'
|
||||||
@listener = Listen.to(Dir.pwd, relative_paths: true, force_polling: @options[:force_polling])
|
|
||||||
@listener.latency(@options[:latency])
|
|
||||||
end
|
|
||||||
|
|
||||||
@listener.change do |modified, added, removed|
|
options = {force_polling: @options[:force_polling]}
|
||||||
|
options[:latency] = @options[:latency] if @options[:latency]
|
||||||
|
|
||||||
|
@listener = Listen.to(Dir.pwd, options) do |modified, added, removed|
|
||||||
added_and_modified = (modified + added)
|
added_and_modified = (modified + added)
|
||||||
|
|
||||||
# See if the changed file is config.rb or lib/*.rb
|
# See if the changed file is config.rb or lib/*.rb
|
||||||
|
@ -131,19 +128,21 @@ module Middleman
|
||||||
@webrick.stop
|
@webrick.stop
|
||||||
else
|
else
|
||||||
added_and_modified.each do |path|
|
added_and_modified.each do |path|
|
||||||
next if app.files.ignored?(path)
|
relative_path = Pathname(path).relative_path_from(Pathname(Dir.pwd)).to_s
|
||||||
app.files.did_change(path)
|
next if app.files.ignored?(relative_path)
|
||||||
|
app.files.did_change(relative_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
removed.each do |path|
|
removed.each do |path|
|
||||||
next if app.files.ignored?(path)
|
relative_path = Pathname(path).relative_path_from(Pathname(Dir.pwd)).to_s
|
||||||
app.files.did_delete(path)
|
next if app.files.ignored?(relative_path)
|
||||||
|
app.files.did_delete(relative_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Don't block this thread
|
# Don't block this thread
|
||||||
@listener.start if first_run
|
@listener.start
|
||||||
end
|
end
|
||||||
|
|
||||||
# Trap some interupt signals and shut down smoothly
|
# Trap some interupt signals and shut down smoothly
|
||||||
|
|
Loading…
Reference in a new issue