Permalink
Browse files

Fix listener for nested dirs.

Closes #362
  • Loading branch information...
1 parent ca4ad92 commit 7c7a59b84bca483ef3fd82e02092e00680263cfb @nex3 nex3 committed May 4, 2012
Showing with 7 additions and 10 deletions.
  1. +7 −10 lib/sass/plugin/listener.rb
@@ -30,15 +30,11 @@ def start!
args = @directories.keys.dup
args << {:force_polling => Sass::Util.windows?}
listener = Listen::MultiListener.new(*args) do |modified, added, removed|
- modified = modified.group_by {|path| File.dirname(path)}
- added = added.group_by {|path| File.dirname(path)}
- removed = removed.group_by {|path| File.dirname(path)}
-
@directories.each do |dir, events|
events.each do |e|
- run_events(modified[dir], e[:modified], dir)
- run_events(added[dir], e[:added], dir)
- run_events(removed[dir], e[:removed], dir)
+ run_events(modified, e[:modified], dir)
+ run_events(added, e[:added], dir)
+ run_events(removed, e[:removed], dir)
end
end
end.start
@@ -54,8 +50,9 @@ def file_event_fn(event, file_base)
end
end
- def run_events(paths, event, path)
- return if paths.nil? || event.nil?
- paths.each {|p| event[File.dirname(p), File.basename(p)]}
+ def run_events(paths, event, dir)
+ return if paths.empty? || event.nil?
+ paths.select {|p| p.start_with?(dir)}.
+ each {|p| event[File.dirname(p), File.basename(p)]}
end
end

0 comments on commit 7c7a59b

Please sign in to comment.