Skip to content

Commit

Permalink
Tear down DiffGenerator notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Jul 9, 2016
1 parent b22c2d8 commit c83f6d3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/nanoc/cli/commands/compile.rb
Expand Up @@ -63,10 +63,10 @@ def start
require 'tempfile'
setup_diffs
old_contents = {}
Nanoc::Int::NotificationCenter.on(:will_write_rep) do |rep, path|
Nanoc::Int::NotificationCenter.on(:will_write_rep, self) do |rep, path|
old_contents[rep] = File.file?(path) ? File.read(path) : nil
end
Nanoc::Int::NotificationCenter.on(:rep_written) do |rep, path, _is_created, _is_modified|
Nanoc::Int::NotificationCenter.on(:rep_written, self) do |rep, path, _is_created, _is_modified|
unless rep.binary?
new_contents = File.file?(path) ? File.read(path) : nil
if old_contents[rep] && new_contents
Expand All @@ -80,6 +80,10 @@ def start
# @see Listener#stop
def stop
super

Nanoc::Int::NotificationCenter.remove(:will_write_rep, self)
Nanoc::Int::NotificationCenter.remove(:rep_written, self)

teardown_diffs
end

Expand Down

0 comments on commit c83f6d3

Please sign in to comment.