brew-bundle: add path support.

Closes Homebrew/homebrew#24384.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Christian Bundy 2013-11-16 17:39:20 -06:00 committed by Mike McQuaid
parent ed7693cecf
commit de12583bb8

View File

@ -1,17 +1,33 @@
# brew-bundle.rb # 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: # For example, given a Brewfile with the following contents:
#
# tap foo/bar # tap foo/bar
# install spark # install spark
# #
# Running `brew bundle` will run the commands `brew tap foo/bar` # Running `brew bundle` will run the commands `brew tap foo/bar`
# and `brew install spark`. # 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
File.readlines('Brewfile').each do |line| raise "No such Brewfile: #{path}" unless File.exist? path
File.readlines(path).each do |line|
command = line.chomp command = line.chomp
next if command.empty? next if command.empty?
next if command.chars.first == '#' next if command.chars.first == '#'