class Jekyll::Commands::Serve

Public Class Methods

init_with_program(prog) click to toggle source
# File lib/patches/idempotent_jekyll_config.rb, line 12
def init_with_program(prog)
  prog.command(:serve) do |cmd|
    cmd.description "Serve your site locally"
    cmd.syntax "serve [options]"
    cmd.alias :server
    cmd.alias :s

    add_build_options(cmd)
    COMMAND_OPTIONS.each do |key, val|
      cmd.option key, *val
    end

    cmd.action do |_, opts|
      opts["serving"] = true
      opts["watch"  ] = true unless opts.key?("watch")

      config = configuration_from_options(opts)
      if Jekyll.env == "development"
        config["url"] = default_url(config)
      end

      Build.process(config)
      Serve.process(config)
    end
  end
end