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:, describe: 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.
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'bundle/adder.rb', line 15 def add(*args, type:, global:, file:, describe: false) item_type = case type when :brew :formula when :cask :cask end if item_type args.each do |arg| tap_with_name = if type == :brew ::Tap.with_formula_name(arg) else ::Tap.with_cask_token(arg) end next unless tap_with_name tap, = tap_with_name tap.ensure_installed! end Homebrew::Trust.trust_fully_qualified_items!(args, type: item_type) end brewfile_path = Brewfile.path(global:, file:) brewfile_path.write("") unless brewfile_path.exist? brewfile = Brewfile.read(global:, file:) content = brewfile.input new_content = args.map do |arg| desc = case type when :brew Formulary.factory(arg).desc when :cask ::Cask::CaskLoader.load(arg).desc end entry = "#{type} \"#{arg}\"" if describe && desc.present? desc.split("\n").map { |s| "# #{s}\n" }.join + entry else entry end end content << new_content.join("\n") << "\n" path = Dumper.brewfile_path(global:, file:) Dumper.write_file path, content end |