Use installed cask file for brew cask zap.

This commit is contained in:
Markus Reiter 2020-08-26 01:56:49 +02:00
parent d3e22f401b
commit 3fb7c3a2f3
2 changed files with 15 additions and 6 deletions

View File

@ -40,11 +40,13 @@ module Cask
casks.each do |cask| casks.each do |cask|
odebug "Uninstalling Cask #{cask}" odebug "Uninstalling Cask #{cask}"
raise CaskNotInstalledError, cask unless cask.installed? || force if cask.installed?
if installed_caskfile = cask.installed_caskfile
if cask.installed? && !cask.installed_caskfile.nil? # Use the same cask file that was used for installation, if possible.
# use the same cask file that was used for installation, if possible cask = CaskLoader.load(installed_caskfile) if installed_caskfile.exist?
cask = CaskLoader.load(cask.installed_caskfile) if cask.installed_caskfile.exist? end
else
raise CaskNotInstalledError, cask unless force
end end
Installer.new(cask, **options).uninstall Installer.new(cask, **options).uninstall

View File

@ -28,7 +28,14 @@ module Cask
casks.each do |cask| casks.each do |cask|
odebug "Zapping Cask #{cask}" odebug "Zapping Cask #{cask}"
raise CaskNotInstalledError, cask unless cask.installed? || args.force? if cask.installed?
if installed_caskfile = cask.installed_caskfile
# Use the same cask file that was used for installation, if possible.
cask = CaskLoader.load(installed_caskfile) if installed_caskfile.exist?
end
else
raise CaskNotInstalledError, cask unless args.force?
end
Installer.new(cask, verbose: args.verbose?, force: args.force?).zap Installer.new(cask, verbose: args.verbose?, force: args.force?).zap
end end