lib/nanoc3/cli/commands/watch.rb in nanoc3-3.2.0a4 vs lib/nanoc3/cli/commands/watch.rb in nanoc3-3.2.0b1

- old
+ new

@@ -1,38 +1,22 @@ # encoding: utf-8 -module Nanoc3::CLI::Commands +usage 'watch [options]' +summary 'start the watcher' +description <<-EOS +Start the watcher. When a change is detected, the site will be recompiled. +EOS - # @since 3.2.0 - class Watch < Cri::Command +run do |opts, args, cmd| + Nanoc3::CLI::Commands::Watch.call(opts, args, cmd) +end - def name - 'watch' - end +module Nanoc3::CLI::Commands - def aliases - [ ] - end + class Watch < ::Nanoc3::CLI::Command - def short_desc - 'start the watcher' - end - - def long_desc - 'Start the watcher. When a change is detected, the site will be ' \ - 'recompiled.' - end - - def usage - "nanoc3 watch" - end - - def option_definitions - [] - end - - def run(options, arguments) + def run require 'fssm' require 'pathname' @notifier = Notifier.new @@ -76,21 +60,22 @@ if notify_on_compilation_failure @notifier.notify('Compilation failed') end puts - @base.print_error(e) + base.print_error(e) puts end end # Rebuild once rebuilder.call(nil, nil) # Get directories to watch - watcher_config = @base.site.config[:watcher] || {} + 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 ) + 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 puts "Watching for changes…".make_compatible_with_env watcher = lambda do |*args| update(&rebuilder)