Class: JekyllPush::Command

Inherits:
Jekyll::Command
  • Object
show all
Defined in:
lib/jekyll_push/command.rb

Class Method Summary collapse

Class Method Details

.init_with_program(prog) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jekyll_push/command.rb', line 8

def init_with_program(prog)
  prog.command(:push) do |c|
    c.syntax 'push [args]'
    c.description 'pushes compiled site to specified github branch'
    c.action do |args, _options|
      raise Error::MissingBranch, "You must specify a target branch name after 'jekyll push'." if args.empty?

      site   = JekyllPush::Site.new
      branch = JekyllPush::Branch.new args.first

      warn Rainbow('Warning: Building the site without a baseurl is not recommended if using GitHub pages.').yellow if site.baseurl.empty? && branch.target == 'gh-pages'

      site.rebuild
      branch.push site.dir

      puts Rainbow("\nDone ✓").green
    end
  end
end