summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-09-03 00:32:51 +0000
committerColby Swandale <me@colby.fyi>2018-09-14 22:26:18 +1000
commit90fc0ced3648717b06329458d73b9e9ef84a51c2 (patch)
tree93b2e487d5858320274b50614aca07b5c0a2699a
parent0e2da805133dd8251f80ba029f5ca27dfa31e646 (diff)
downloadbundler-90fc0ced3648717b06329458d73b9e9ef84a51c2.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. (cherry picked from commit d9ffe1ecaf459baef83f08f481a15e7f72738c81)
-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 78880adfc2..6e13b8f9f4 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