diff options
| author | Markus Reiter | 2016-10-01 23:18:13 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-10-02 19:53:43 +0200 |
| commit | 082bd5e98ae7592bc92466186609066e00c2bf84 (patch) | |
| tree | 6afaa394d36b9d21517a41e47264ffb9c63780f8 /Library | |
| parent | 564fa8867dd865c686d243ba48c202e0cb6a35fe (diff) | |
| download | brew-082bd5e98ae7592bc92466186609066e00c2bf84.tar.bz2 | |
Change `A Cask for #{token} is already installed.` message.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/install.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/exceptions.rb | 23 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/installer.rb | 7 | ||||
| -rw-r--r-- | Library/Homebrew/cask/test/cask/installer_test.rb | 2 |
4 files changed, 25 insertions, 9 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/install.rb b/Library/Homebrew/cask/lib/hbc/cli/install.rb index d7575344d..996de8d1b 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/install.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/install.rb @@ -27,7 +27,7 @@ module Hbc rescue CaskAlreadyInstalledError => e opoo e.message count += 1 - rescue CaskAutoUpdatesError => e + rescue CaskAlreadyInstalledAutoUpdatesError => e opoo e.message count += 1 rescue CaskUnavailableError => e diff --git a/Library/Homebrew/cask/lib/hbc/exceptions.rb b/Library/Homebrew/cask/lib/hbc/exceptions.rb index f77106d92..2f63366ca 100644 --- a/Library/Homebrew/cask/lib/hbc/exceptions.rb +++ b/Library/Homebrew/cask/lib/hbc/exceptions.rb @@ -29,13 +29,30 @@ module Hbc class CaskAlreadyInstalledError < AbstractCaskErrorWithToken def to_s - %Q{A Cask for #{token} is already installed. Add the "--force" option to force re-install.} + s = <<-EOS.undent + A Cask for #{token} is already installed. + EOS + + s.concat("\n").concat(reinstall_message) + end + + private + + def reinstall_message + <<-EOS.undent + To re-install #{token}, run: + brew cask uninstall --force #{token}; brew cask install #{token} + EOS end end - class CaskAutoUpdatesError < AbstractCaskErrorWithToken + class CaskAlreadyInstalledAutoUpdatesError < CaskAlreadyInstalledError def to_s - %Q{A Cask for #{token} is already installed and using auto-updates. Add the "--force" option to force re-install.} + s = <<-EOS.undent + A Cask for #{token} is already installed and using auto-updates. + EOS + + s.concat("\n").concat(reinstall_message) end end diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 4d29acb75..9575aa181 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -58,12 +58,11 @@ module Hbc def install odebug "Hbc::Installer.install" - if @cask.installed? && @cask.auto_updates && !force - raise CaskAutoUpdatesError, @cask + if @cask.installed? && !force + raise CaskAlreadyInstalledAutoUpdatesError, @cask if @cask.auto_updates + raise CaskAlreadyInstalledError, @cask end - raise CaskAlreadyInstalledError, @cask if @cask.installed? && !force - print_caveats begin diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb index 2275c3080..64a0e9b87 100644 --- a/Library/Homebrew/cask/test/cask/installer_test.rb +++ b/Library/Homebrew/cask/test/cask/installer_test.rb @@ -272,7 +272,7 @@ describe Hbc::Installer do lambda { installer.install - }.must_raise(Hbc::CaskAutoUpdatesError) + }.must_raise(Hbc::CaskAlreadyInstalledAutoUpdatesError) end it "allows already-installed Casks which auto-update to be installed if force is provided" do |
