Class: Cask::Reinstall Private

Inherits:
Object show all
Extended by:
Utils::Output::Mixin
Defined in:
cask/reinstall.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Class Method Summary collapse

Methods included from Utils::Output::Mixin

issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_deprecated, pretty_disabled, pretty_duration, pretty_install_status, pretty_installed, pretty_uninstalled, pretty_unmarked, pretty_upgradable, pretty_warning

Class Method Details

.reinstall_casks(*casks, verbose: false, force: false, skip_cask_deps: false, binaries: false, require_sha: false, zap: false, skip_prefetch: false, download_queue: nil, cask_installers: nil) ⇒ Array<Cask>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • casks (::Cask::Cask)
  • verbose (Boolean) (defaults to: false)
  • force (Boolean) (defaults to: false)
  • skip_cask_deps (Boolean) (defaults to: false)
  • binaries (Boolean) (defaults to: false)
  • require_sha (Boolean) (defaults to: false)
  • zap (Boolean) (defaults to: false)
  • skip_prefetch (Boolean) (defaults to: false)
  • download_queue (Homebrew::DownloadQueue, nil) (defaults to: nil)
  • cask_installers (Array<Installer>, nil) (defaults to: nil)

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'cask/reinstall.rb', line 20

def self.reinstall_casks(
  *casks,
  verbose: false,
  force: false,
  skip_cask_deps: false,
  binaries: false,
  require_sha: false,
  zap: false,
  skip_prefetch: false,
  download_queue: nil,
  cask_installers: nil
)
  created_download_queue = T.let(false, T::Boolean)
  if download_queue.nil?
    if skip_prefetch
      download_queue = Homebrew.default_download_queue
    else
      download_queue = Homebrew::DownloadQueue.new(pour: true)
      created_download_queue = true
    end
  end

  cask_installers = T.let(cask_installers || [], T::Array[Installer])
  begin
    if cask_installers.empty?
      cask_installers = casks.map do |cask|
        Installer.new(
          cask,
          binaries:,
          verbose:,
          force:,
          skip_cask_deps:,
          require_sha:,
          reinstall:      true,
          zap:,
          download_queue:,
          defer_fetch:    true,
        )
      end
    end

    unless skip_prefetch
      Homebrew::Install.enqueue_cask_installers(cask_installers, download_queue:)
      download_queue.fetch(
        heading: "Fetching dependency downloads",
      )
    end
  ensure
    download_queue.shutdown if created_download_queue
  end

  # Reinstall everything that did download and report each failure as it
  # happens, rather than aborting the whole run; the failures still exit
  # nonzero at the end.
  reinstalled_casks = T.let([], T::Array[Cask])
  cask_installers.each do |installer|
    installer.install
    reinstalled_casks << installer.cask
  rescue => e
    ofail "#{installer.cask.full_name}: #{e}"
  end
  reinstalled_casks
end