class Guard::Nanoc::LiveCommand

Public Instance Methods

run() click to toggle source
# File lib/guard/nanoc/live_command.rb, line 19
def run
  require 'guard'
  require 'guard/commander'

  if defined?(Nanoc::Live)
    $stderr.puts '-' * 40
    $stderr.puts 'NOTE:'
    $stderr.puts 'You are using the `nanoc live` command provided by `guard-nanoc`, but the `nanoc-live` gem is also installed, which also provides a `nanoc live` command.'
    if defined?(Bundler)
      $stderr.puts 'Recommendation: Remove `guard-nanoc` from your Gemfile.'
    else
      $stderr.puts 'Recommendation: Uninstall `guard-nanoc`.'
    end
    $stderr.puts '-' * 40
  end

  Thread.new do
    break if ENV['__NANOC_DEV_LIVE_DISABLE_VIEW']

    # Crash the entire process if the viewer dies for some reason (e.g.
    # the port is already bound).
    Thread.current.abort_on_exception = true
    ::Nanoc::CLI::Commands::View.new(options, arguments, command).run
  end

  ::Guard.start(no_interactions: true)
end