summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-07-20 11:27:40 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-07-20 11:27:40 -0500
commitd53ed27a64fd022a4c92d787fe2822306e7c6891 (patch)
tree6a6a2a61e63640f977c39bb603af11a920bf7bee
parent53dfec6917c9fd2795856cbd776cff2029a0416e (diff)
downloadbundler-seg-no-bundler-versio-warning-when-parseable.tar.gz
[CLI] Dont print an outdated version warning when running a parseable commandseg-no-bundler-versio-warning-when-parseable
-rw-r--r--lib/bundler/cli.rb19
-rw-r--r--spec/bundler/cli_spec.rb15
2 files changed, 27 insertions, 7 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index cd4391279a..a1ad3055ca 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -6,6 +6,9 @@ require "bundler/vendored_thor"
module Bundler
class CLI < Thor
AUTO_INSTALL_CMDS = %w[show binstubs outdated exec open console licenses clean].freeze
+ PARSEABLE_COMMANDS = %w[
+ check config help exec platform show version
+ ].freeze
def self.start(*)
super
@@ -13,12 +16,14 @@ module Bundler
Bundler.ui = UI::Shell.new
raise e
ensure
- warn_on_outdated_bundler
Bundler::SharedHelpers.print_major_deprecations!
end
def self.dispatch(*)
- super {|i| i.send(:print_command) }
+ super do |i|
+ i.send(:print_command)
+ i.send(:warn_on_outdated_bundler)
+ end
end
def initialize(*args)
@@ -641,7 +646,7 @@ module Bundler
_, _, config = @_initializer
current_command = config[:current_command]
command_name = current_command.name
- return if %w[exec version check platform show help].include?(command_name)
+ return if PARSEABLE_COMMANDS.include?(command_name)
command = ["bundle", command_name] + args
options_to_print = options.dup
options_to_print.delete_if do |k, v|
@@ -653,9 +658,14 @@ module Bundler
Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}"
end
- def self.warn_on_outdated_bundler
+ def warn_on_outdated_bundler
return if Bundler.settings[:disable_version_check]
+ _, _, config = @_initializer
+ current_command = config[:current_command]
+ command_name = current_command.name
+ return if PARSEABLE_COMMANDS.include?(command_name)
+
latest = Fetcher::CompactIndex.
new(nil, Source::Rubygems::Remote.new(URI("https://rubygems.org")), nil).
send(:compact_index_client).
@@ -672,6 +682,5 @@ module Bundler
rescue
nil
end
- private_class_method :warn_on_outdated_bundler
end
end
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb
index 2ef2eb3412..5283027ca0 100644
--- a/spec/bundler/cli_spec.rb
+++ b/spec/bundler/cli_spec.rb
@@ -57,8 +57,9 @@ RSpec.describe "bundle executable" do
context "with --verbose" do
it "prints the running command" do
- bundle! "config", :verbose => true
- expect(last_command.stdout).to start_with("Running `bundle config --verbose` with bundler #{Bundler::VERSION}")
+ gemfile ""
+ bundle! "info bundler", :verbose => true
+ expect(last_command.stdout).to start_with("Running `bundle info bundler --no-color --verbose` with bundler #{Bundler::VERSION}")
end
it "doesn't print defaults" do
@@ -120,6 +121,16 @@ To update, run `gem install bundler`
include_examples "no warning"
end
+ context "running a parseable command" do
+ it "prints no warning" do
+ bundle! "config --parseable foo"
+ expect(last_command.stdboth).to eq ""
+
+ bundle "platform --ruby"
+ expect(last_command.stdboth).to eq "Could not locate Gemfile"
+ end
+ end
+
context "and is a pre-release" do
let(:latest_version) { "2.0.0.pre.4" }
it "prints the version warning" do