Merge pull request #8485 from reitermarkus/cask-zap-installed

Use installed cask file for `brew cask zap`.
This commit is contained in:
Markus Reiter 2020-08-26 03:06:53 +02:00 committed by GitHub
commit b14bc2857b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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