diff options
| -rw-r--r-- | lib/bundler/cli/config.rb | 15 | ||||
| -rw-r--r-- | spec/bundler/bundler/cli_spec.rb | 4 | ||||
| -rw-r--r-- | spec/bundler/commands/config_spec.rb | 15 | ||||
| -rw-r--r-- | spec/bundler/other/major_deprecation_spec.rb | 2 |
4 files changed, 27 insertions, 9 deletions
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index 6a77e4a65e..3ac973cfe1 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -88,15 +88,26 @@ module Bundler if value.nil? warn_unused_scope "Ignoring --#{scope} since no value to set was given" + configured = Bundler.settings.locations(name).any? + if options[:parseable] if value = Bundler.settings[name] Bundler.ui.info("#{name}=#{value}") end - return + if configured + return + else + exit 1 + end end confirm(name) - return + + if configured + return + else + exit 1 + end end Bundler.ui.info(message) if message diff --git a/spec/bundler/bundler/cli_spec.rb b/spec/bundler/bundler/cli_spec.rb index d1e6d7d411..56caf9937e 100644 --- a/spec/bundler/bundler/cli_spec.rb +++ b/spec/bundler/bundler/cli_spec.rb @@ -251,8 +251,10 @@ To update to the most recent version, run `bundle update --bundler` context "running a parseable command" do it "prints no warning" do + bundle "config set foo value", env: { "BUNDLER_VERSION" => bundler_version } bundle "config get --parseable foo", env: { "BUNDLER_VERSION" => bundler_version } - expect(stdboth).to eq "" + expect(out).to eq "foo=value" + expect(err).to eq "" bundle "platform --ruby", env: { "BUNDLER_VERSION" => bundler_version }, raise_on_error: false expect(stdboth).to eq "Could not locate Gemfile" diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 5cafbe3468..0aaae98ccb 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -313,9 +313,10 @@ RSpec.describe ".bundle/config" do describe "parseable option" do it "prints an empty string" do - bundle "config get foo --parseable" + bundle "config get foo --parseable", raise_on_error: false expect(out).to eq "" + expect(last_command).to be_failure end it "only prints the value of the config" do @@ -501,8 +502,9 @@ E it "get" do ENV["BUNDLE_BAR"] = "bar_val" - bundle "config get foo" + bundle "config get foo", raise_on_error: false expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(last_command).to be_failure ENV["BUNDLE_FOO"] = "foo_val" @@ -547,7 +549,8 @@ E bundle "config unset foo" expect(out).to eq "" - expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(bundle("config get foo", raise_on_error: false)).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(last_command).to be_failure bundle "config set --local foo 1" bundle "config set --global foo 2" @@ -557,7 +560,8 @@ E expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for the current user (#{home(".bundle/config")}): \"2\"" bundle "config unset foo --global" expect(out).to eq "" - expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(bundle("config get foo", raise_on_error: false)).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(last_command).to be_failure bundle "config set --local foo 1" bundle "config set --global foo 2" @@ -567,7 +571,8 @@ E expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for your local app (#{bundled_app(".bundle/config")}): \"1\"" bundle "config unset foo --local" expect(out).to eq "" - expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(bundle("config get foo", raise_on_error: false)).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(last_command).to be_failure bundle "config unset foo --local --global", raise_on_error: false expect(last_command).to be_failure diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index 6eeb70abe5..ab7589d698 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -290,7 +290,7 @@ RSpec.describe "major deprecations" do describe "old get interface" do before do - bundle "config waka" + bundle "config waka", raise_on_error: false end it "warns", bundler: "4" do |
