diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2018-10-01 20:35:15 -0300 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2018-10-01 21:26:59 -0300 |
commit | 2dd62a3896e743e8be6101d9872cc291cfc2f969 (patch) | |
tree | bb3dd712a0dbb9336d7c32cf2eb14bf89a503c11 | |
parent | fefd4c970f0c7010722213be2358bbc794e47241 (diff) | |
download | bundler-2dd62a3896e743e8be6101d9872cc291cfc2f969.tar.gz |
Fix `--paths` argument handling
-rw-r--r-- | lib/bundler/cli.rb | 10 | ||||
-rw-r--r-- | spec/commands/show_spec.rb | 15 |
2 files changed, 23 insertions, 2 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 55c3ebf2d3..da648fa45e 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -294,8 +294,16 @@ module Bundler rest = ARGV[1..-1] alternative = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list" + new_argv = [alternative, *rest] + + if alternative == "list" && rest.include?("--paths") + new_argv.delete("--paths") + else + new_argv = new_argv.map {|arg| arg == "--paths" ? "--path" : arg } + end + old_argv = ARGV.join(" ") - new_argv = [alternative, *rest].join(" ") + new_argv = new_argv.join(" ") Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") end diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index 382924f3a1..102b9534de 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -38,6 +38,19 @@ RSpec.describe "bundle show" do ) end + it "prints path if gem exists in bundle (with --paths option)", :bundler => "< 2" do + bundle "show rails --paths" + expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) + end + + it "prints path if gem exists in bundle (with --paths option)", :bundler => "2" do + bundle "show rails --paths" + expect(out).to eq( + "[DEPRECATED FOR 2.0] use `bundle info rails --path` instead of `bundle show rails --paths`\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")) @@ -83,7 +96,7 @@ RSpec.describe "bundle show" do 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`") + expect(out_lines[0]).to eq("[DEPRECATED FOR 2.0] use `bundle list` 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 } |