Specify version constraint in subcommand error message. (#5974)
Merge pull request 5974
This commit is contained in:
parent
bdcdfa694f
commit
b807799f24
|
@ -25,13 +25,13 @@ Mercenary.program(:jekyll) do |p|
|
|||
"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|
|
||||
Jekyll::External.require_if_present(Jekyll::External.blessed_gems) do |g, ver_constraint|
|
||||
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."
|
||||
" version #{ver_constraint} to use the 'jekyll #{cmd}' command."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,12 +23,25 @@ module Jekyll
|
|||
require name
|
||||
rescue LoadError
|
||||
Jekyll.logger.debug "Couldn't load #{name}. Skipping."
|
||||
yield(name) if block_given?
|
||||
yield(name, version_constraint(name)) if block_given?
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# The version constraint required to activate a given gem.
|
||||
# Usually the gem version requirement is "> 0," because any version
|
||||
# will do. In the case of jekyll-docs, however, we require the exact
|
||||
# same version as Jekyll.
|
||||
#
|
||||
# Returns a String version constraint in a parseable form for
|
||||
# RubyGems.
|
||||
def version_constraint(gem_name)
|
||||
return "= #{Jekyll::VERSION}" if gem_name.to_s.eql?("jekyll-docs")
|
||||
"> 0"
|
||||
end
|
||||
|
||||
#
|
||||
# Require a gem or gems. If it's not present, show a very nice error
|
||||
# message that explains everything and is much more helpful than the
|
||||
|
|
Loading…
Reference in New Issue