For blessed gems, shim their commands so users know how to use them.
This commit is contained in:
parent
10a1b9451a
commit
4fe9eecf05
14
bin/jekyll
14
bin/jekyll
|
@ -6,10 +6,6 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w( .. lib ))
|
|||
require 'jekyll'
|
||||
require 'mercenary'
|
||||
|
||||
Jekyll::External.require_if_present(
|
||||
Jekyll::External.blessed_gems
|
||||
)
|
||||
|
||||
Jekyll::PluginManager.require_from_bundler
|
||||
|
||||
Jekyll::Deprecator.process(ARGV)
|
||||
|
@ -26,6 +22,16 @@ Mercenary.program(:jekyll) do |p|
|
|||
p.option 'layouts_dir', '--layouts DIR', String, 'Layouts directory (defaults to ./_layouts)'
|
||||
p.option 'profile', '--profile', 'Generate a Liquid rendering profile'
|
||||
|
||||
Jekyll::External.require_if_present(Jekyll::External.blessed_gems) do |g|
|
||||
cmd = g.split('-').last
|
||||
p.command(cmd.to_sym) do |c|
|
||||
c.syntax cmd
|
||||
c.action do
|
||||
Jekyll.logger.abort_with "You must install the '#{g}' gem to use the 'jekyll #{cmd}' command."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Jekyll::Command.subclasses.each { |c| c.init_with_program(p) }
|
||||
|
||||
p.action do |args, _|
|
||||
|
|
|
@ -17,12 +17,13 @@ module Jekyll
|
|||
#
|
||||
# names - a string gem name or array of gem names
|
||||
#
|
||||
def require_if_present(names)
|
||||
def require_if_present(names, &block)
|
||||
Array(names).each do |name|
|
||||
begin
|
||||
require name
|
||||
rescue LoadError
|
||||
Jekyll.logger.debug "Couldn't load #{name}. Skipping."
|
||||
block.call(name) if block
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue