Skip to content

Commit

Permalink
Allow uninstall to raise an exception when cask token cannot be loade…
Browse files Browse the repository at this point in the history
…d. (#23328)
  • Loading branch information
reitermarkus committed Aug 13, 2016
1 parent 1dcce03 commit 986b14f
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/hbc/cli/uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ def self.run(*args)

cask_tokens.each do |cask_token|
odebug "Uninstalling Cask #{cask_token}"
cask = Hbc::Cask.new(cask_token)
cask = Hbc.load(cask_token)

unless cask.installed?
cask.caskroom_path.rmtree if cask.caskroom_path.exist?
raise Hbc::CaskNotInstalledError, cask unless force
end
raise Hbc::CaskNotInstalledError, cask unless cask.installed? || force

latest_installed_version = cask.timestamped_versions.last

Expand All @@ -21,11 +18,7 @@ def self.run(*args)
"Casks", "#{cask_token}.rb")

# use the same cask file that was used for installation, if possible
cask = if latest_installed_cask_file.exist?
Hbc.load(latest_installed_cask_file)
else
Hbc.load(cask_token)
end
cask = Hbc.load(latest_installed_cask_file) if latest_installed_cask_file.exist?
end

Hbc::Installer.new(cask, force: force).uninstall
Expand Down

0 comments on commit 986b14f

Please sign in to comment.