aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/cask')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/reinstall.rb28
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb25
2 files changed, 27 insertions, 26 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb b/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb
index b52c43328..c2ed8f462 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb
@@ -7,30 +7,10 @@ module Hbc
begin
cask = CaskLoader.load(cask_token)
- installer = Installer.new(cask,
- force: force,
- skip_cask_deps: skip_cask_deps,
- require_sha: require_sha)
- installer.print_caveats
- installer.fetch
-
- if cask.installed?
- # use copy of cask for uninstallation to avoid 'No such file or directory' bug
- installed_cask = cask
-
- # 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
-
- # Always force uninstallation, ignore method parameter
- Installer.new(installed_cask, force: true).uninstall
- end
-
- installer.stage
- installer.install_artifacts
- installer.enable_accessibility_access
- puts installer.summary
+ Installer.new(cask,
+ force: force,
+ skip_cask_deps: skip_cask_deps,
+ require_sha: require_sha).reinstall
count += 1
rescue CaskUnavailableError => e
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 26022953b..f02f07806 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -24,6 +24,7 @@ module Hbc
@force = force
@skip_cask_deps = skip_cask_deps
@require_sha = require_sha
+ @reinstall = false
end
def self.print_caveats(cask)
@@ -76,13 +77,16 @@ module Hbc
def install
odebug "Hbc::Installer#install"
- if @cask.installed? && !force
+ if @cask.installed? && !force && !@reinstall
raise CaskAlreadyInstalledAutoUpdatesError, @cask if @cask.auto_updates
raise CaskAlreadyInstalledError, @cask
end
print_caveats
fetch
+ uninstall_existing_cask if @reinstall
+
+ oh1 "Installing Cask #{@cask}"
stage
install_artifacts
enable_accessibility_access
@@ -90,6 +94,23 @@ module Hbc
puts summary
end
+ def reinstall
+ odebug "Hbc::Installer#reinstall"
+ @reinstall = true
+ install
+ end
+
+ def uninstall_existing_cask
+ return unless @cask.installed?
+
+ # use the same cask file that was used for installation, if possible
+ 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
+ end
+
def summary
s = ""
s << "#{Emoji.install_badge} " if Emoji.enabled?
@@ -305,7 +326,7 @@ module Hbc
end
def uninstall
- odebug "Hbc::Installer#uninstall"
+ oh1 "Uninstalling Cask #{@cask}"
disable_accessibility_access
uninstall_artifacts
purge_versioned_files