Class: Kompo::HomebrewPath::Install
- Inherits:
-
Taski::Task
- Object
- Taski::Task
- Kompo::HomebrewPath::Install
- Defined in:
- lib/kompo/tasks/homebrew.rb
Overview
Install Homebrew
Constant Summary collapse
- MARKER_FILE =
File.("~/.kompo_installed_homebrew")
Instance Method Summary collapse
Instance Method Details
#clean ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/kompo/tasks/homebrew.rb', line 61 def clean # Only uninstall if kompo installed it return unless File.exist?(MARKER_FILE) puts "Uninstalling Homebrew (installed by kompo)..." system('NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"') File.delete(MARKER_FILE) if File.exist?(MARKER_FILE) puts "Homebrew uninstalled" end |
#run ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/kompo/tasks/homebrew.rb', line 38 def run puts "Homebrew not found. Installing..." system('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"') brew_in_path, = Open3.capture2("which", "brew", err: File::NULL) @path = brew_in_path.chomp if @path.empty? # Check common installation paths HomebrewPath::COMMON_BREW_PATHS.each do |p| if File.executable?(p) @path = p break end end end raise "Failed to install Homebrew" if @path.nil? || @path.empty? # Mark that kompo installed Homebrew File.write(MARKER_FILE, @path) puts "Homebrew installed at: #{@path}" end |