aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorChristian Bundy2013-11-16 17:39:20 -0600
committerMike McQuaid2013-11-17 09:42:18 +0000
commitde12583bb81a2752951d3bba633a8b13094069c3 (patch)
treea3c9da79a08f286b4894e258b3c0c622da981576 /Library
parented7693cecf677a5e55a450be2065168e4ebefdb7 (diff)
downloadbrew-de12583bb81a2752951d3bba633a8b13094069c3.tar.bz2
brew-bundle: add path support.
Closes Homebrew/homebrew#24384. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Contributions/cmd/brew-bundle.rb24
1 files changed, 20 insertions, 4 deletions
diff --git a/Library/Contributions/cmd/brew-bundle.rb b/Library/Contributions/cmd/brew-bundle.rb
index a533c093e..2924e1093 100755
--- a/Library/Contributions/cmd/brew-bundle.rb
+++ b/Library/Contributions/cmd/brew-bundle.rb
@@ -1,17 +1,33 @@
# brew-bundle.rb
-# Looks for a "Brewfile" in the current directory and runs each line
-# as a brew command.
+#
+# Usage: brew bundle [path]
+#
+# Looks for a Brewfile and runs each line as a brew command.
+#
+# brew bundle # Looks for "./brewfile"
+# brew bundle path/to/dir # Looks for "./path/to/dir/brewfile"
+# brew bundle path/to/file # Looks for "./path/to/file"
#
# For example, given a Brewfile with the following contents:
+#
# tap foo/bar
# install spark
#
# Running `brew bundle` will run the commands `brew tap foo/bar`
# and `brew install spark`.
-raise 'Cannot find Brewfile' unless File.exist? 'Brewfile'
+if ARGV.empty? then
+ path = 'brewfile'
+else
+ path = ARGV[0]
+ if File.directory? path then
+ path = path + '/brewfile'
+ end
+end
+
+raise "No such Brewfile: #{path}" unless File.exist? path
-File.readlines('Brewfile').each do |line|
+File.readlines(path).each do |line|
command = line.chomp
next if command.empty?
next if command.chars.first == '#'