Class: Jekyll::Commands::Build

Inherits:
Jekyll::Command show all
Defined in:
lib/jekyll/commands/build.rb

Class Method Summary collapse

Methods inherited from Jekyll::Command

add_build_options, configuration_from_options, inherited, process_site, subclasses

Class Method Details

.build(site, options) ⇒ Object

Build your Jekyll site.

site - the Jekyll::Site instance to build options - A Hash of options passed to the command

Returns nothing.



50
51
52
53
54
55
56
57
58
# File 'lib/jekyll/commands/build.rb', line 50

def build(site, options)
  source      = options['source']
  destination = options['destination']
  Jekyll.logger.info "Source:", source
  Jekyll.logger.info "Destination:", destination
  Jekyll.logger.info "Generating..."
  process_site(site)
  Jekyll.logger.info "", "done."
end

.init_with_program(prog) ⇒ Object

Create the Mercenary command for the Jekyll CLI for this Command



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jekyll/commands/build.rb', line 8

def init_with_program(prog)
  prog.command(:build) do |c|
    c.syntax      'build [options]'
    c.description 'Build your site'
    c.alias :b

    add_build_options(c)

    c.action do |args, options|
      options["serving"] = false
      Jekyll::Commands::Build.process(options)
    end
  end
end

.process(options) ⇒ Object

Build your jekyll site Continuously watch if ‘watch` is set to true in the config.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jekyll/commands/build.rb', line 25

def process(options)
  Jekyll.logger.log_level = :error if options['quiet']

  options = configuration_from_options(options)
  site = Jekyll::Site.new(options)

  if options.fetch('skip_initial_build', false)
    Jekyll.logger.warn "Build Warning:", "Skipping the initial build. This may result in an out-of-date site."
  else
    build(site, options)
  end

  if options.fetch('watch', false)
    watch(site, options)
  else
    Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
  end
end

.watch(site, options) ⇒ Object

Private: Watch for file changes and rebuild the site.

site - A Jekyll::Site instance options - A Hash of options passed to the command

Returns nothing.



66
67
68
69
# File 'lib/jekyll/commands/build.rb', line 66

def watch(site, options)
  Deprecator.gracefully_require 'jekyll-watch'
  Jekyll::Watcher.watch(options)
end