aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-06-14 12:51:36 +0200
committerMarkus Reiter2017-06-14 12:51:36 +0200
commit599a618273a64db1852f4bb80e21ee0c410a3285 (patch)
tree5a7ea3fec32adda2ae3c8cebbd9d86ab3423041c /Library/Homebrew/utils.rb
parent5a047c7c27685a8576fb0f8c420700d2dc564bfc (diff)
downloadbrew-599a618273a64db1852f4bb80e21ee0c410a3285.tar.bz2
Move `require?` to `utils`.
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 85305c01a..529f3492d 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -15,6 +15,14 @@ require "utils/svn"
require "utils/tty"
require "time"
+def require?(path)
+ return false if path.nil?
+ require path
+rescue LoadError => e
+ # we should raise on syntax errors but not if the file doesn't exist.
+ raise unless e.message.include?(path)
+end
+
def ohai(title, *sput)
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
puts Formatter.headline(title, color: :blue)