Sha256: 051985fdfd09e469d9f8b2f04434c8e205438850984cb5611850dea752044d7f

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require_relative 'configuration'

# Allows us to add more option parameter to the serve command
module Mercenary
  class Command
    def command(cmd_name)
      Jekyll.logger.debug "Refined Command"
      cmd = @commands[cmd_name] || Command.new(cmd_name, self)
      yield cmd
      @commands[cmd_name] = cmd
    end
  end
end

# Monkey Patch the Serve command to do a few things before the built-in
# Serve command methods are invoked.
module Jekyll
  module Livereload
    module Serve
      include Livereload::Configuration

      def init_with_program(prog)
        prog.command(:serve) do |c|
          c.option 'livereload', '-L', '--livereload', 'Inject Livereload.js and run a WebSocket Server'
          c.option 'reload_port', '-R', '--reload_port [PORT]', Integer, 'Port to serve Livereload on'
        end

        super prog
      end

      def process(opts)
        opts = load_config_options(opts)
        if opts['livereload']
          Livereload.reactor = Livereload::Reactor.new(opts)
          Livereload.reactor.start
        end

        super opts
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jekyll-livereload-0.2.2 lib/jekyll-livereload/serve.rb
jekyll-livereload-0.2.1 lib/jekyll-livereload/serve.rb
jekyll-livereload-0.1.1.1 lib/jekyll-livereload/serve.rb