Module: Homebrew::Bundle::Commands::Check Private

Defined in:
bundle/commands/check.rb

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

Class Method Summary collapse

Class Method Details

.run(global: false, file: nil, no_upgrade: false, verbose: false, quiet: false) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • global (Boolean) (defaults to: false)
  • file (String, nil) (defaults to: nil)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • quiet (Boolean) (defaults to: false)


14
15
16
17
18
19
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
# File 'bundle/commands/check.rb', line 14

def self.run(global: false, file: nil, no_upgrade: false, verbose: false, quiet: false)
  output_errors = verbose
  exit_on_first_error = !verbose
  check_result = Homebrew::Bundle::Checker.check(
    global:, file:,
    exit_on_first_error:, no_upgrade:, verbose:
  )

  # Allow callers of `brew bundle check` to specify when they've already
  # output some formulae errors.
  check_missing_formulae = ENV.fetch("HOMEBREW_BUNDLE_CHECK_ALREADY_OUTPUT_FORMULAE_ERRORS", "")
                              .strip
                              .split

  if check_result.work_to_be_done
    puts "brew bundle can't satisfy your Brewfile's dependencies." if check_missing_formulae.blank?

    if output_errors
      check_result.errors.each do |error|
        if (match = error.match(/^Formula (.+) needs to be installed/)) &&
           check_missing_formulae.include?(match[1])
          next
        end

        puts "#{error}"
      end
    end

    puts "Satisfy missing dependencies with `brew bundle install`."
    exit 1
  end

  puts "The Brewfile's dependencies are satisfied." unless quiet
end