diff --git a/rake/lib/git.rb b/rake/lib/git.rb index 39b857e3..8ba57e75 100644 --- a/rake/lib/git.rb +++ b/rake/lib/git.rb @@ -1,7 +1,7 @@ include Rake::DSL def git(url,dest) - sh "git clone #{url} #{dest}" unless File.exists?(dest) + sh "git clone #{url} #{dest}" unless Dir.exists?(dest) end def github(repo,dest) diff --git a/rake/lib/homebrew.rb b/rake/lib/homebrew.rb index 8122c3e8..79901697 100644 --- a/rake/lib/homebrew.rb +++ b/rake/lib/homebrew.rb @@ -38,26 +38,34 @@ module Homebrew end def self.has_keg?(keg) - system("#{BIN} search #{keg}") + `#{BIN} search #{keg}` end def self.is_keg_installed?(keg) - system("#{BIN} list | grep -w '#{keg}'") + `#{BIN} list | grep -w '#{keg}'` end def self.is_cask_installed?(cask) - system("#{BIN} cask list | grep -w '#{cask}'") + `#{BIN} cask list | grep -w '#{cask}'` end def self.is_tapped?(tap) - system("#{BIN} tap | grep -w '#{tap}'") + `#{BIN} tap | grep -w '#{tap}'` end def self.is_installed? - File.exists?("usr/local/bin/brew") + File.exists?("/usr/local/bin/brew") end - - def self.update() - sh "#{BIN} update && #{BIN} upgrade" + + def self.prefix(keg) + `#{BIN} --prefix #{keg}`.strip + end + + def self.update(*args) + if args.length > 0 + sh "#{BIN} upgrade #{args.join(' ')}" + else + sh "#{BIN} update && #{BIN} upgrade" + end end end diff --git a/rake/lib/output.rb b/rake/lib/output.rb index f042f060..898c7e6e 100644 --- a/rake/lib/output.rb +++ b/rake/lib/output.rb @@ -3,3 +3,7 @@ require 'colorize' def echo(msg) puts "=> #{msg}".bold.green end + +def echoerr(msg) + puts "=> #{msg}".bold.red +end