Merge pull request #4254 from jekyll/shim-docs-import-with-nudge
Merge pull request 4254
This commit is contained in:
commit
f995d86673
21
bin/jekyll
21
bin/jekyll
|
@ -6,10 +6,6 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w( .. lib ))
|
||||||
require 'jekyll'
|
require 'jekyll'
|
||||||
require 'mercenary'
|
require 'mercenary'
|
||||||
|
|
||||||
Jekyll::External.require_if_present(
|
|
||||||
Jekyll::External.blessed_gems
|
|
||||||
)
|
|
||||||
|
|
||||||
Jekyll::PluginManager.require_from_bundler
|
Jekyll::PluginManager.require_from_bundler
|
||||||
|
|
||||||
Jekyll::Deprecator.process(ARGV)
|
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 'layouts_dir', '--layouts DIR', String, 'Layouts directory (defaults to ./_layouts)'
|
||||||
p.option 'profile', '--profile', 'Generate a Liquid rendering profile'
|
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) }
|
Jekyll::Command.subclasses.each { |c| c.init_with_program(p) }
|
||||||
|
|
||||||
p.action do |args, _|
|
p.action do |args, _|
|
||||||
|
@ -34,8 +40,11 @@ Mercenary.program(:jekyll) do |p|
|
||||||
puts p
|
puts p
|
||||||
abort
|
abort
|
||||||
else
|
else
|
||||||
unless p.has_command?(args.first)
|
subcommand = args.first
|
||||||
Jekyll.logger.abort_with "Invalid command. Use --help for more information"
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,12 +17,13 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# names - a string gem name or array of gem names
|
# 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|
|
Array(names).each do |name|
|
||||||
begin
|
begin
|
||||||
require name
|
require name
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
Jekyll.logger.debug "Couldn't load #{name}. Skipping."
|
Jekyll.logger.debug "Couldn't load #{name}. Skipping."
|
||||||
|
block.call(name) if block
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue