summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryoka <[email protected]>2022-12-31 10:58:34 +0200
committergit <[email protected]>2023-01-04 13:13:19 +0000
commit799d805e215e3bdcc2e9bbdb48638a129b50e8f4 (patch)
tree97d99b666b2f86458c664551e05e3a6e3216bf0d
parent87c17a141dc4491abf5282d164f2cba13ade18c4 (diff)
[rubygems/rubygems] Raise invalid option when bundle open --path is called without a value
https://github.com/rubygems/rubygems/commit/c242311158
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/open.rb1
-rw-r--r--spec/bundler/commands/open_spec.rb5
3 files changed, 7 insertions, 1 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 3f8d0bd0e6..ee73bdb506 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -509,7 +509,7 @@ module Bundler
subcommand "config", Config
desc "open GEM", "Opens the source directory of the given bundled gem"
- method_option "path", :type => :string, :banner => "Open relative path of the gem source."
+ method_option "path", :type => :string, :lazy_default => "", :banner => "Open relative path of the gem source."
def open(name)
require_relative "cli/open"
Open.new(options, name).run
diff --git a/lib/bundler/cli/open.rb b/lib/bundler/cli/open.rb
index ebd86fd4b1..8522ec92d6 100644
--- a/lib/bundler/cli/open.rb
+++ b/lib/bundler/cli/open.rb
@@ -10,6 +10,7 @@ module Bundler
end
def run
+ raise InvalidOption, "Cannot specify `--path` option without a value" if [email protected]? && @path.empty?
editor = [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? }
return Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") unless editor
return unless spec = Bundler::CLI::Common.select_spec(name, :regex_match)
diff --git a/spec/bundler/commands/open_spec.rb b/spec/bundler/commands/open_spec.rb
index 570e0f5961..e30ebfea5b 100644
--- a/spec/bundler/commands/open_spec.rb
+++ b/spec/bundler/commands/open_spec.rb
@@ -73,6 +73,11 @@ RSpec.describe "bundle open" do
expect(out).to include("editor #{default_bundle_path("gems", "activerecord-2.3.2")}/lib/active_record")
end
+ it "requires value for --path arg" do
+ bundle "open activerecord --path", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, :raise_on_error => false
+ expect(err).to eq "Cannot specify `--path` option without a value"
+ end
+
it "suggests alternatives for similar-sounding gems when using subpath" do
bundle "open Rails --path README.md", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }, :raise_on_error => false
expect(err).to match(/did you mean rails\?/i)