Module: Ddenv::Homebrew

Defined in:
lib/ddenv/homebrew.rb

Class Method Summary collapse

Class Method Details

.package_installed?(package_name) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
# File 'lib/ddenv/homebrew.rb', line 7

def package_installed?(package_name)
  # TODO: use :pretty when passing --verbose
  cmd = TTY::Command.new(printer: :null)

  stdout, _stderr = cmd.run("brew", "info", "--json", package_name)
  info = JSON.parse(stdout)

  !info[0].fetch("installed").empty?
end