Sha256: 58489c1dec5be8e96d4ca60a3469aa4dbdf57b6b81a53d701f884f8f57f06f03

Contents?: true

Size: 1.38 KB

Versions: 12

Compression:

Stored size: 1.38 KB

Contents

require 'bin_install/brew/cask'
require 'bin_install/brew/package'
require 'bin_install/brew/service'

module BinInstall
  module Brew
    def self.require!
      if installed?
        update!
      else
        puts 'Homebrew is required.'.red
        puts 'Visit https://brew.sh/ for more information.'
        ask!
        abort('Can not continue without Homebrew.'.red) unless installed?
      end
    end

    def self.install
      puts 'Installing Homebrew...'.white
      system('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
    end

    def self.install!
      puts 'Installing Homebrew...'.white
      BinInstall.system!('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
    end

    def self.ask
      return if installed?

      print 'Would you like to install Homebrew? [Y/n]: '
      install if Shell.default_yes?(gets.chomp)
    end

    def self.ask!
      print 'Would you like to install Homebrew? [Y/n]: '
      install! if Shell.default_yes?(gets.chomp)
    end

    def self.update
      puts 'Updating Homebrew...'.white
      system('brew update')
      Cask.tap
    end

    def self.update!
      puts 'Updating Homebrew...'.white
      BinInstall.system!('brew update')
      Cask.tap!
    end

    def self.installed?
      Shell.executable_exists?('brew')
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bin_install-0.0.20 lib/bin_install/brew.rb
bin_install-0.0.19 lib/bin_install/brew.rb
bin_install-0.0.18 lib/bin_install/brew.rb
bin_install-0.0.17 lib/bin_install/brew.rb
bin_install-0.0.16 lib/bin_install/brew.rb
bin_install-0.0.15 lib/bin_install/brew.rb
bin_install-0.0.14 lib/bin_install/brew.rb
bin_install-0.0.13 lib/bin_install/brew.rb
bin_install-0.0.12 lib/bin_install/brew.rb
bin_install-0.0.11 lib/bin_install/brew.rb
bin_install-0.0.10 lib/bin_install/brew.rb
bin_install-0.0.9 lib/bin_install/brew.rb