Skip to content

Commit

Permalink
Fix the Listen plugin.
Browse files Browse the repository at this point in the history
Closes #372
Closes #370
Closes #362
  • Loading branch information
Maher4Ever authored and nex3 committed Apr 27, 2012
1 parent 60a9db3 commit 0a2eafd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions doc-src/SASS_CHANGELOG.md
Expand Up @@ -7,6 +7,8 @@


* Don't crash when calling `#inspect` on an internal Sass tree object in Ruby * Don't crash when calling `#inspect` on an internal Sass tree object in Ruby
1.9. 1.9.
* Fix some bugs in `sass --watch` introduces in 3.1.16. Thanks to [Maher
Sallam](https://github.com/Maher4Ever).


## 3.1.16 ## 3.1.16


Expand Down
14 changes: 8 additions & 6 deletions lib/sass/plugin/listener.rb
Expand Up @@ -14,20 +14,22 @@ def initialize
end end


def directory(path, events) def directory(path, events)
(@directories[path] ||= []) << events (@directories[File.expand_path(path)] ||= []) << events
end end


def file(path, events) def file(path, events)
file_base = File.basename(path) file_base = File.basename(path)
directory(File.dirname(path), { directory(File.dirname(path), {
:modified => file_event_fn(events[:modified], file_base), :modified => file_event_fn(events[:modified], file_base),
:added => file_event_fn(events[:added], file_base), :added => file_event_fn(events[:added], file_base),
:removed => file_event_fn(events[:removed], file_base) :removed => file_event_fn(events[:removed], file_base)
}) })
end end


def start! def start!
listener = Listen::MultiListener.new(*@directories.keys) do |modified, added, removed| 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)} modified = modified.group_by {|path| File.dirname(path)}
added = added.group_by {|path| File.dirname(path)} added = added.group_by {|path| File.dirname(path)}
removed = removed.group_by {|path| File.dirname(path)} removed = removed.group_by {|path| File.dirname(path)}
Expand Down

0 comments on commit 0a2eafd

Please sign in to comment.