summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-09-03 00:32:51 +0000
committerThe Bundler Bot <bot@bundler.io>2018-09-03 00:32:51 +0000
commitd9ffe1ecaf459baef83f08f481a15e7f72738c81 (patch)
treeaf0ce5732deb75beafc6ada567725f25b3e4c70f
parent4e215b74197581de3b11cf3e2948d604da7ca2d6 (diff)
parent2b7762318e9e376022ed2885a1b3b922cab6a62f (diff)
downloadbundler-d9ffe1ecaf459baef83f08f481a15e7f72738c81.tar.gz
Auto merge of #6682 - bundler:bundle_env_formatting, r=colby-swandale
Remove extra new lines from `bundle env` output ### What was the end-user problem that led to this PR? When reporting my `bundle env` for https://github.com/bundler/bundler/issues/6677, I noticed an extra blank line between the `rbenv` and the `chruby` lines. Not really a big problem, other than people like me getting distracted by those little inconsistencies. ### What was your diagnosis of the problem? My diagnosis was that the formatting method was somewhere unintentionally printing an extra new line. After checking it out, it looks like any versions that are grabbed by shelling out to `#{tool} --version` will have this problem, since the new line from the subprocess output is included in the `bundle env` output, together with its own line returns. ### What is your fix for the problem, implemented in this PR? My fix is to prune any trailing new lines from the output of those subprocesses. ### Why did you choose this fix out of the possible options? I chose this fix because it seemed like the simplest way to fix the issue.
-rw-r--r--lib/bundler/env.rb2
-rw-r--r--spec/bundler/env_spec.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
index 923a14de0c..171b6520ad 100644
--- a/lib/bundler/env.rb
+++ b/lib/bundler/env.rb
@@ -88,7 +88,7 @@ module Bundler
def self.version_of(script)
return "not installed" unless Bundler.which(script)
- `#{script} --version`
+ `#{script} --version`.chomp
end
def self.chruby_version
diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb
index 83c03e67d5..10762b3cd2 100644
--- a/spec/bundler/env_spec.rb
+++ b/spec/bundler/env_spec.rb
@@ -140,4 +140,12 @@ RSpec.describe Bundler::Env do
end
end
end
+
+ describe ".version_of" do
+ let(:parsed_version) { described_class.send(:version_of, "ruby") }
+
+ it "strips version of new line characters" do
+ expect(parsed_version).to_not include("\n")
+ end
+ end
end