lib/nanoc3/cli/commands/watch.rb in nanoc3-3.2.1 vs lib/nanoc3/cli/commands/watch.rb in nanoc3-3.2.2

- old
+ new

@@ -16,10 +16,12 @@ def run require 'fssm' require 'pathname' + watcher_config = self.site.config[:watcher] || {} + @notifier = Notifier.new # Define rebuilder rebuilder = lambda do |base, relative| # Determine filename @@ -41,24 +43,20 @@ site = Nanoc3::Site.new('.') begin site.compile # TODO include icon (--image misc/success-icon.png) - notify_on_compilation_success = site.config.has_key?(:notify_on_compilation_success) ? - site.config[:notify_on_compilation_success] : - true + notify_on_compilation_success = watcher_config.fetch(:notify_on_compilation_success) { true } if notify_on_compilation_success @notifier.notify('Compilation complete') end time_spent = ((Time.now - start)*1000.0).round puts "done in #{format '%is %ims', *(time_spent.divmod(1000))}" rescue Exception => e # TODO include icon (--image misc/error-icon.png) - notify_on_compilation_failure = site.config.has_key?(:notify_on_compilation_failure) ? - site.config[:notify_on_compilation_failure] : - true + notify_on_compilation_failure = watcher_config.fetch(:notify_on_compilation_failure) { true } if notify_on_compilation_failure @notifier.notify('Compilation failed') end puts @@ -69,10 +67,9 @@ # Rebuild once rebuilder.call(nil, nil) # Get directories to watch - watcher_config = self.site.config[:watcher] || {} dirs_to_watch = watcher_config[:dirs_to_watch] || %w( content layouts lib ) files_to_watch = watcher_config[:files_to_watch] || %w( config.yaml Rules rules Rules.rb rules.rb' ) files_to_watch.delete_if { |f| !File.file?(f) } # Watch