summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColby Swandale <colby@taplaboratories.com>2017-04-12 20:20:03 +1000
committerColby Swandale <colby@taplaboratories.com>2017-04-12 20:20:03 +1000
commitb6c30144033a36c116525550ae3e13637b30f021 (patch)
treee75048286135a2e696cae37dce57ab693e02320e
parent3a76965b54e6ffc7d8325241ec75204dcf5732b0 (diff)
downloadbundler-b6c30144033a36c116525550ae3e13637b30f021.tar.gz
print old config value in parseable format using overwriting an existing
value
-rw-r--r--lib/bundler/cli/config.rb5
-rw-r--r--spec/commands/config_spec.rb11
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb
index 70eeac4015..8ad7f12fac 100644
--- a/lib/bundler/cli/config.rb
+++ b/lib/bundler/cli/config.rb
@@ -79,7 +79,10 @@ module Bundler
def message
locations = Bundler.settings.locations(name)
- if scope == "global"
+ if @options[:parseable]
+ value = locations[:local] || locations[:env] || locations[:global]
+ "#{name}=#{value}" if value
+ elsif scope == "global"
if locations[:local]
"Your application has set #{name} to #{locations[:local].inspect}. " \
"This will override the global value you are currently setting"
diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb
index 4ce323c3a9..030a85ff62 100644
--- a/spec/commands/config_spec.rb
+++ b/spec/commands/config_spec.rb
@@ -142,6 +142,16 @@ RSpec.describe ".bundle/config" do
run "puts Bundler.settings['foo']"
expect(out).to eq("value")
end
+
+ context "when replacing a current value with the parseable flag" do
+ before { bundle "config --global foo value" }
+ it "prints the current value in a parseable format" do
+ bundle "config --global --parseable foo value2"
+ expect(out).to eq "foo=value"
+ run "puts Bundler.settings['foo']"
+ expect(out).to eq("value2")
+ end
+ end
end
describe "local" do
@@ -191,6 +201,7 @@ RSpec.describe ".bundle/config" do
it "can be deleted with parseable option" do
bundle "config --local foo value"
bundle "config --delete --parseable foo"
+ expect(out).to eq ""
run "puts Bundler.settings['foo'] == nil"
expect(out).to eq("true")
end