diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2018-10-01 19:54:25 -0300 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2018-10-01 21:26:59 -0300 |
commit | fefd4c970f0c7010722213be2358bbc794e47241 (patch) | |
tree | 187281184c94caf8b1962b5126a73ff787e5dff9 | |
parent | 9deb5447da89453c22686819782b034e62583b6b (diff) | |
download | bundler-fefd4c970f0c7010722213be2358bbc794e47241.tar.gz |
Fix "bundle show" deprecation messages
With a single gem, it will be replaced by `bundle info`, not by `bundle
list`.
-rw-r--r-- | lib/bundler/cli.rb | 10 | ||||
-rw-r--r-- | spec/commands/show_spec.rb | 38 |
2 files changed, 43 insertions, 5 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 53241b15f6..55c3ebf2d3 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -290,7 +290,15 @@ module Bundler method_option "outdated", :type => :boolean, :banner => "Show verbose output including whether gems are outdated." def show(gem_name = nil) - Bundler::SharedHelpers.major_deprecation(2, "use `bundle list` instead of `bundle show`") if ARGV[0] == "show" + if ARGV[0] == "show" + rest = ARGV[1..-1] + alternative = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list" + + old_argv = ARGV.join(" ") + new_argv = [alternative, *rest].join(" ") + + Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") + end require "bundler/cli/show" Show.new(options, gem_name).run end diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index 0bdf6a4a9c..382924f3a1 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle show", :bundler => "< 2" do +RSpec.describe "bundle show" do context "with a standard Gemfile" do before :each do install_gemfile <<-G @@ -25,11 +25,19 @@ RSpec.describe "bundle show", :bundler => "< 2" do expect(bundled_app("Gemfile.lock")).to exist end - it "prints path if gem exists in bundle" do + it "prints path if gem exists in bundle", :bundler => "< 2" do bundle "show rails" expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) end + it "prints path if gem exists in bundle", :bundler => "2" do + bundle "show rails" + expect(out).to eq( + "[DEPRECATED FOR 2.0] use `bundle info rails` instead of `bundle show rails`\n" + + default_bundle_path("gems", "rails-2.3.2").to_s + ) + end + it "warns if path no longer exists on disk" do FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2")) @@ -39,17 +47,25 @@ RSpec.describe "bundle show", :bundler => "< 2" do and include(default_bundle_path("gems", "rails-2.3.2").to_s) end - it "prints the path to the running bundler" do + it "prints the path to the running bundler", :bundler => "< 2" do bundle "show bundler" expect(out).to eq(root.to_s) end + it "prints the path to the running bundler", :bundler => "2" do + bundle "show bundler" + expect(out).to eq( + "[DEPRECATED FOR 2.0] use `bundle info bundler` instead of `bundle show bundler`\n" + + root.to_s + ) + end + it "complains if gem not in bundle" do bundle "show missing" expect(out).to match(/could not find gem 'missing'/i) end - it "prints path of all gems in bundle sorted by name" do + it "prints path of all gems in bundle sorted by name", :bundler => "< 2" do bundle "show --paths" expect(out).to include(default_bundle_path("gems", "rake-10.0.2").to_s) @@ -60,6 +76,20 @@ RSpec.describe "bundle show", :bundler => "< 2" do expect(gem_list).to eq(gem_list.sort) end + it "prints path of all gems in bundle sorted by name", :bundler => "2" do + bundle "show --paths" + + expect(out).to include(default_bundle_path("gems", "rake-10.0.2").to_s) + expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s) + + out_lines = out.split("\n") + expect(out_lines[0]).to eq("[DEPRECATED FOR 2.0] use `bundle list --paths` instead of `bundle show --paths`") + + # Gem names are the last component of their path. + gem_list = out_lines[1..-1].map {|p| p.split("/").last } + expect(gem_list).to eq(gem_list.sort) + end + it "prints summary of gems" do bundle "show --verbose" |