Merge pull request #4116 from commitay/zap-force

Fix `zap --force` for uninstalled casks
This commit is contained in:
commitay 2018-05-11 08:42:03 +10:00 committed by GitHub
commit 2b6f477143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 7 deletions

View File

@ -58,7 +58,7 @@ module Hbc
end end
unless target.exist? unless target.exist?
return if skip return if skip || force
raise CaskError, "It seems the #{self.class.english_name} source '#{target}' is not there." raise CaskError, "It seems the #{self.class.english_name} source '#{target}' is not there."
end end

View File

@ -11,6 +11,9 @@ module Hbc
def run def run
casks.each do |cask| casks.each do |cask|
odebug "Zapping Cask #{cask}" odebug "Zapping Cask #{cask}"
raise CaskNotInstalledError, cask unless cask.installed? || force?
Installer.new(cask, verbose: verbose?, force: force?).zap Installer.new(cask, verbose: verbose?, force: force?).zap
end end
end end

View File

@ -123,11 +123,11 @@ names, and other aspects of this manual are still subject to change.
If `--greedy` is given then also upgrade the Casks having `auto_updates true` If `--greedy` is given then also upgrade the Casks having `auto_updates true`
or `version :latest`. or `version :latest`.
* `zap` <token> [ <token> ... ]: * `zap` [--force] <token> [ <token> ... ]:
Unconditionally remove _all_ files associated with the given Cask. Unconditionally remove _all_ files associated with the given Cask.
With `--force`, zap even if the Cask does not appear to be currently installed.
Implicitly performs all actions associated with `uninstall`, even if Implicitly performs all actions associated with `uninstall`.
the Cask does not appear to be currently installed.
Removes all staged versions of the Cask distribution found under Removes all staged versions of the Cask distribution found under
`<Caskroom_path>/`<token>. `<Caskroom_path>/`<token>.

View File

@ -118,11 +118,11 @@ Uninstall the given Cask\. With \fB\-\-force\fR, uninstall even if the Cask does
Without token arguments, upgrade all the installed Casks that have newer versions available in the tap; otherwise update the tokens given in the command line\. If \fB\-\-greedy\fR is given then also upgrade the Casks having \fBauto_updates true\fR or \fBversion :latest\fR\. Without token arguments, upgrade all the installed Casks that have newer versions available in the tap; otherwise update the tokens given in the command line\. If \fB\-\-greedy\fR is given then also upgrade the Casks having \fBauto_updates true\fR or \fBversion :latest\fR\.
. .
.TP .TP
\fBzap\fR \fItoken\fR [ \fItoken\fR \.\.\. ] \fBzap\fR [\-\-force] \fItoken\fR [ \fItoken\fR \.\.\. ]
Unconditionally remove \fIall\fR files associated with the given Cask\. Unconditionally remove \fIall\fR files associated with the given Cask\. With \fB\-\-force\fR, zap even if the Cask does not appear to be currently installed\.
. .
.IP .IP
Implicitly performs all actions associated with \fBuninstall\fR, even if the Cask does not appear to be currently installed\. Implicitly performs all actions associated with \fBuninstall\fR\.
. .
.IP .IP
Removes all staged versions of the Cask distribution found under \fB<Caskroom_path>/\fR\fItoken\fR\. Removes all staged versions of the Cask distribution found under \fB<Caskroom_path>/\fR\fItoken\fR\.