Skip to content

Commit

Permalink
Add --version parameter to bundle info command.
Browse files Browse the repository at this point in the history
  • Loading branch information
simi committed Dec 6, 2021
1 parent 7befe7e commit 7d9fdd9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions bundler/lib/bundler/cli.rb
Expand Up @@ -331,6 +331,7 @@ def list

desc "info GEM [OPTIONS]", "Show information for the given gem"
method_option "path", :type => :boolean, :banner => "Print full path to gem"
method_option "version", :type => :boolean, :banner => "Print gem version"
def info(gem_name)
require_relative "cli/info"
Info.new(options, gem_name).run
Expand Down
5 changes: 5 additions & 0 deletions bundler/lib/bundler/cli/info.rb
Expand Up @@ -18,6 +18,7 @@ def run

if spec
return print_gem_path(spec) if @options[:path]
return print_gem_version(spec) if @options[:version]
print_gem_info(spec)
end
end
Expand All @@ -39,6 +40,10 @@ def spec_not_found(gem_name)
raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(gem_name, Bundler.definition.dependencies)
end

def print_gem_version(spec)
Bundler.ui.info spec.version.to_s
end

def print_gem_path(spec)
name = spec.name
if name == "bundler"
Expand Down
5 changes: 5 additions & 0 deletions bundler/spec/commands/info_spec.rb
Expand Up @@ -50,6 +50,11 @@
expect(out).to eq(root.to_s)
end

it "prints gem version if exists in bundle" do
bundle "info rails --version"
expect(out).to eq("2.3.2")
end

it "doesn't claim that bundler has been deleted, even if using a custom path without bundler there" do
bundle "config set --local path vendor/bundle"
bundle "install"
Expand Down

0 comments on commit 7d9fdd9

Please sign in to comment.