Make file watcher paths relative
This commit is contained in:
parent
5866540dd8
commit
cf66ddf206
|
@ -53,9 +53,17 @@ module Middleman
|
||||||
require "listen"
|
require "listen"
|
||||||
|
|
||||||
Listen.to(Dir.pwd) do |modified, added, removed|
|
Listen.to(Dir.pwd) do |modified, added, removed|
|
||||||
local.run_on_change(modified) if modified.length > 0
|
added_and_modified = modified + added
|
||||||
local.run_on_change(added) if added.length > 0
|
|
||||||
local.run_on_deletion(removed) if removed.length > 0
|
if added_and_modified.length > 0
|
||||||
|
added_and_modified.map! { |p| p.sub(Dir.pwd, "").sub(/^\//, "") }
|
||||||
|
local.run_on_change(added_and_modified)
|
||||||
|
end
|
||||||
|
|
||||||
|
if removed.length > 0
|
||||||
|
removed_relative = removed.map! { |p| p.sub(Dir.pwd, "").sub(/^\//, "") }
|
||||||
|
local.run_on_deletion(removed_relative)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -138,7 +146,7 @@ module Middleman
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def run_on_change(paths)
|
def run_on_change(paths)
|
||||||
# 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?(paths)
|
return reload if needs_to_reload?(paths)
|
||||||
|
|
||||||
# Otherwise forward to Middleman
|
# Otherwise forward to Middleman
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
|
@ -151,7 +159,7 @@ module Middleman
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def run_on_deletion(paths)
|
def run_on_deletion(paths)
|
||||||
# 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?(paths)
|
return reload if needs_to_reload?(paths)
|
||||||
|
|
||||||
# Otherwise forward to Middleman
|
# Otherwise forward to Middleman
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
|
@ -162,15 +170,16 @@ module Middleman
|
||||||
private
|
private
|
||||||
# Trap the interupt signal and shut down FSSM (and thus the server) smoothly
|
# Trap the interupt signal and shut down FSSM (and thus the server) smoothly
|
||||||
def register_signal_handlers
|
def register_signal_handlers
|
||||||
# trap("INT") { stop; exit(0) }
|
trap("INT") { stop; exit(0) }
|
||||||
trap("TERM") { stop }
|
trap("TERM") { stop }
|
||||||
# trap("QUIT") { stop; exit(0) }
|
trap("QUIT") { stop; exit(0) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Whether the passed files are config.rb, lib/*.rb or helpers
|
# Whether the passed files are config.rb, lib/*.rb or helpers
|
||||||
# @param [Array<String>] paths Array of paths to check
|
# @param [Array<String>] paths Array of paths to check
|
||||||
# @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)
|
||||||
|
return false # disable reloading for now
|
||||||
paths.any? do |path|
|
paths.any? do |path|
|
||||||
path.match(%{^config\.rb}) || path.match(%r{^lib/^[^\.](.*)\.rb$}) || path.match(%r{^helpers/^[^\.](.*)_helper\.rb$})
|
path.match(%{^config\.rb}) || path.match(%r{^lib/^[^\.](.*)\.rb$}) || path.match(%r{^helpers/^[^\.](.*)_helper\.rb$})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue