Module: Homebrew::Bundle::Adder Private

Defined in:
bundle/adder.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

.add(*args, type:, global:, file:) ⇒ 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:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'bundle/adder.rb', line 13

def add(*args, type:, global:, file:)
  brewfile = Brewfile.read(global:, file:)
  content = brewfile.input
  # TODO: - support `:describe`
  new_content = args.map do |arg|
    case type
    when :brew
      Formulary.factory(arg)
    when :cask
      Cask::CaskLoader.load(arg)
    end

    "#{type} \"#{arg}\""
  end

  content << new_content.join("\n") << "\n"
  path = Dumper.brewfile_path(global:, file:)

  Dumper.write_file path, content
end