2025-03-18 17:38:37 +00:00
|
|
|
# typed: true # rubocop:todo Sorbet/StrictSigil
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
module Bundle
|
|
|
|
module TapInstaller
|
2025-03-21 04:24:55 +00:00
|
|
|
def self.preinstall(name, verbose: false, **_options)
|
2025-03-18 17:38:37 +00:00
|
|
|
if installed_taps.include? name
|
|
|
|
puts "Skipping install of #{name} tap. It is already installed." if verbose
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2025-03-21 04:24:55 +00:00
|
|
|
def self.install(name, preinstall: true, verbose: false, force: false, **options)
|
2025-03-18 17:38:37 +00:00
|
|
|
return true unless preinstall
|
|
|
|
|
|
|
|
puts "Installing #{name} tap. It is not currently installed." if verbose
|
|
|
|
args = []
|
|
|
|
args << "--force" if force
|
|
|
|
|
|
|
|
success = if options[:clone_target]
|
|
|
|
Bundle.brew("tap", name, options[:clone_target], *args, verbose:)
|
|
|
|
else
|
|
|
|
Bundle.brew("tap", name, *args, verbose:)
|
|
|
|
end
|
|
|
|
|
|
|
|
unless success
|
2025-03-24 21:55:47 +08:00
|
|
|
require "bundle/skipper"
|
2025-03-18 17:38:37 +00:00
|
|
|
Homebrew::Bundle::Skipper.tap_failed!(name)
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
installed_taps << name
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2025-03-21 04:24:55 +00:00
|
|
|
def self.installed_taps
|
2025-03-24 21:55:47 +08:00
|
|
|
require "bundle/tap_dumper"
|
2025-03-18 17:38:37 +00:00
|
|
|
@installed_taps ||= Homebrew::Bundle::TapDumper.tap_names
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|