Use listen gem's built in relative_path support
This commit is contained in:
parent
9a7fd0f8d4
commit
37fc5b2b8c
|
@ -52,17 +52,15 @@ module Middleman
|
||||||
# Watcher Library
|
# Watcher Library
|
||||||
require "listen"
|
require "listen"
|
||||||
|
|
||||||
Listen.to(Dir.pwd) do |modified, added, removed|
|
Listen.to(Dir.pwd, :relative_paths => true) do |modified, added, removed|
|
||||||
added_and_modified = modified + added
|
added_and_modified = modified + added
|
||||||
|
|
||||||
if added_and_modified.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)
|
local.run_on_change(added_and_modified)
|
||||||
end
|
end
|
||||||
|
|
||||||
if removed.length > 0
|
if removed.length > 0
|
||||||
removed_relative = removed.map! { |p| p.sub(Dir.pwd, "").sub(/^\//, "") }
|
local.run_on_deletion(removed)
|
||||||
local.run_on_deletion(removed_relative)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -193,4 +191,4 @@ module Middleman
|
||||||
Net::HTTP.post_form(uri, {}.merge(params))
|
Net::HTTP.post_form(uri, {}.merge(params))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue