From cb28ab640e191500d480308ca262366184518022 Mon Sep 17 00:00:00 2001 From: Joshua McKinney Date: Mon, 17 Apr 2017 17:21:02 -0700 Subject: [PATCH] Refactor uninstall existing cask --- Library/Homebrew/cask/lib/hbc/installer.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index c9b6b4e538..51b0490f5e 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -84,7 +84,7 @@ module Hbc print_caveats fetch - uninstall_if_neccessary + uninstall_existing_cask if @reinstall oh1 "Installing Cask #{@cask}" stage @@ -100,14 +100,12 @@ module Hbc install end - def uninstall_if_neccessary - return unless @cask.installed? && @reinstall - installed_cask = @cask + def uninstall_existing_cask + return unless @cask.installed? # use the same cask file that was used for installation, if possible - if (installed_caskfile = installed_cask.installed_caskfile).exist? - installed_cask = CaskLoader.load_from_file(installed_caskfile) - end + installed_caskfile = @cask.installed_caskfile + installed_cask = installed_caskfile.exist? ? CaskLoader.load_from_file(installed_caskfile) : @cask # Always force uninstallation, ignore method parameter Installer.new(installed_cask, force: true).uninstall