check for cask before unlinking during uninstall

this was exposed in #313 by @vitorgalvao in his attempt to update the
anvil cask; by adding a link to that cask, (which just so happens to be
the cask that we chose for our "already uninstalled message" test).

the fix is simply to move the "already uninstalled" check *before* we
start to unlink.
This commit is contained in:
Paul Hinze 2013-05-12 19:55:30 -05:00
parent 245a5fb33d
commit a89494860a
3 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,7 @@
class Anvil < Cask
url 'http://anvilformac.com/download'
url 'http://sparkler.herokuapp.com/apps/3/download'
homepage 'http://anvilformac.com/'
version 'latest'
no_checksum
link :app, 'Anvil.app'
end

View File

@ -3,10 +3,11 @@ class Cask::CLI::Uninstall
begin
casks = cask_names.map { |cn| Cask.load(cn) }
casks.each do |cask|
raise CaskNotInstalledError.new(cask) unless cask.installed?
Cask::AppLinker.new(cask).unlink
Cask::Installer.uninstall(cask)
end
rescue CaskUnavailableError,CaskNotInstalledError => e
rescue CaskError => e
onoe e
end
end

View File

@ -28,8 +28,6 @@ class Cask::Installer
end
def uninstall(cask)
raise CaskNotInstalledError.new(cask) unless cask.installed?
cask.destination_path.rmtree
end