Class: Guard::Nanoc::LiveCommand

Inherits:
Nanoc::CLI::CommandRunner
  • Object
show all
Defined in:
lib/guard/nanoc/live_command.rb

Instance Method Summary collapse

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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