Merge pull request #4254 from jekyll/shim-docs-import-with-nudge

Merge pull request 4254
This commit is contained in:
Parker Moore 2016-01-04 16:30:30 -08:00
commit f995d86673
2 changed files with 17 additions and 7 deletions

View File

@ -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, _|
@ -34,8 +40,11 @@ Mercenary.program(:jekyll) do |p|
puts p
abort
else
unless p.has_command?(args.first)
Jekyll.logger.abort_with "Invalid command. Use --help for more information"
subcommand = args.first
unless p.has_command? subcommand
Jekyll.logger.abort_with "fatal: 'jekyll #{args.first}' could not" \
" be found. You may need to install the jekyll-#{args.first} gem" \
" or a related gem to be able to use this subcommand."
end
end
end

View File

@ -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