diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-08-01 10:41:41 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-08-01 10:41:41 -0500 |
commit | 23e9287ae6f230d5dd47451f9082665c2847070b (patch) | |
tree | d0b0db6c454e7372eb0359b100ba92b9b1ee331d | |
parent | db82c57899d5057a8baabcdb7f53db9603a6505a (diff) | |
download | bundler-seg-outdated-warning-tweak.tar.gz |
[CLI] Suggest bundle update --bundler when a newer version is installedseg-outdated-warning-tweak
-rw-r--r-- | lib/bundler/cli.rb | 11 | ||||
-rw-r--r-- | spec/bundler/cli_spec.rb | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 31f5bb04c8..745145b951 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -677,8 +677,17 @@ module Bundler current = Gem::Version.new(VERSION) return if current >= latest + latest_installed = Bundler.rubygems.find_name("bundler").map(&:version).max - Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\nTo update, run `gem install bundler#{" --pre" if latest.prerelease?}`" + installation = "To install the latest version, run `gem install bundler#{" --pre" if latest.prerelease?}`" + if latest_installed && latest_installed > current + suggestion = "To update to the most recent installed version, run `bundle update --bundler`" + suggestion = "#{installation}\n#{suggestion}" if latest_installed > latest + else + suggestion = installation + end + + Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}" rescue nil end diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index 5283027ca0..59576f41db 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -112,7 +112,7 @@ RSpec.describe "bundle executable" do bundle "fail" expect(last_command.stdout).to start_with(<<-EOS.strip) The latest bundler is #{latest_version}, but you are currently running #{bundler_version}. -To update, run `gem install bundler` +To install the latest version, run `gem install bundler` EOS end @@ -137,7 +137,7 @@ To update, run `gem install bundler` bundle "fail" expect(last_command.stdout).to start_with(<<-EOS.strip) The latest bundler is #{latest_version}, but you are currently running #{bundler_version}. -To update, run `gem install bundler --pre` +To install the latest version, run `gem install bundler --pre` EOS end end |