Merge pull request #1207 from reitermarkus/cask-already-installed-warning
Change `A Cask for #{token} is already installed.` message.
This commit is contained in:
commit
7e70ebd4f1
@ -27,7 +27,7 @@ module Hbc
|
|||||||
rescue CaskAlreadyInstalledError => e
|
rescue CaskAlreadyInstalledError => e
|
||||||
opoo e.message
|
opoo e.message
|
||||||
count += 1
|
count += 1
|
||||||
rescue CaskAutoUpdatesError => e
|
rescue CaskAlreadyInstalledAutoUpdatesError => e
|
||||||
opoo e.message
|
opoo e.message
|
||||||
count += 1
|
count += 1
|
||||||
rescue CaskUnavailableError => e
|
rescue CaskUnavailableError => e
|
||||||
|
|||||||
@ -29,13 +29,30 @@ module Hbc
|
|||||||
|
|
||||||
class CaskAlreadyInstalledError < AbstractCaskErrorWithToken
|
class CaskAlreadyInstalledError < AbstractCaskErrorWithToken
|
||||||
def to_s
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
class CaskAutoUpdatesError < AbstractCaskErrorWithToken
|
class CaskAlreadyInstalledAutoUpdatesError < CaskAlreadyInstalledError
|
||||||
def to_s
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -48,21 +65,19 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
<<-EOS
|
s = "Command failed to execute!\n"
|
||||||
Command failed to execute!
|
s.concat("\n")
|
||||||
|
s.concat("==> Failed command:\n")
|
||||||
==> Failed command:
|
s.concat(@cmd).concat("\n")
|
||||||
#{@cmd}
|
s.concat("\n")
|
||||||
|
s.concat("==> Standard Output of failed command:\n")
|
||||||
==> Standard Output of failed command:
|
s.concat(@stdout).concat("\n")
|
||||||
#{@stdout}
|
s.concat("\n")
|
||||||
|
s.concat("==> Standard Error of failed command:\n")
|
||||||
==> Standard Error of failed command:
|
s.concat(@stderr).concat("\n")
|
||||||
#{@stderr}
|
s.concat("\n")
|
||||||
|
s.concat("==> Exit status of failed command:\n")
|
||||||
==> Exit status of failed command:
|
s.concat(@status.inspect).concat("\n")
|
||||||
#{@status.inspect}
|
|
||||||
EOS
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -58,12 +58,11 @@ module Hbc
|
|||||||
def install
|
def install
|
||||||
odebug "Hbc::Installer.install"
|
odebug "Hbc::Installer.install"
|
||||||
|
|
||||||
if @cask.installed? && @cask.auto_updates && !force
|
if @cask.installed? && !force
|
||||||
raise CaskAutoUpdatesError, @cask
|
raise CaskAlreadyInstalledAutoUpdatesError, @cask if @cask.auto_updates
|
||||||
|
raise CaskAlreadyInstalledError, @cask
|
||||||
end
|
end
|
||||||
|
|
||||||
raise CaskAlreadyInstalledError, @cask if @cask.installed? && !force
|
|
||||||
|
|
||||||
print_caveats
|
print_caveats
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -29,7 +29,7 @@ describe Hbc::CLI::Install do
|
|||||||
|
|
||||||
TestHelper.must_output(self, lambda {
|
TestHelper.must_output(self, lambda {
|
||||||
Hbc::CLI::Install.run("local-transmission", "")
|
Hbc::CLI::Install.run("local-transmission", "")
|
||||||
}, %r{Warning: A Cask for local-transmission is already installed. Add the "--force" option to force re-install.})
|
}, %r{Warning: A Cask for local-transmission is already installed.})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows double install with --force" do
|
it "allows double install with --force" do
|
||||||
|
|||||||
@ -272,7 +272,7 @@ describe Hbc::Installer do
|
|||||||
|
|
||||||
lambda {
|
lambda {
|
||||||
installer.install
|
installer.install
|
||||||
}.must_raise(Hbc::CaskAutoUpdatesError)
|
}.must_raise(Hbc::CaskAlreadyInstalledAutoUpdatesError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows already-installed Casks which auto-update to be installed if force is provided" do
|
it "allows already-installed Casks which auto-update to be installed if force is provided" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user