Use listen gem's built in relative_path support

This commit is contained in:
Ben Hollis 2012-04-22 18:24:02 -07:00
parent 9a7fd0f8d4
commit 37fc5b2b8c

View file

@ -52,17 +52,15 @@ module Middleman
# Watcher Library
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
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)
local.run_on_deletion(removed)
end
end
end
@ -193,4 +191,4 @@ module Middleman
Net::HTTP.post_form(uri, {}.merge(params))
end
end
end
end