diff options
| author | Christian Bundy | 2013-11-16 17:39:20 -0600 |
|---|---|---|
| committer | Mike McQuaid | 2013-11-17 09:42:18 +0000 |
| commit | 21146eaa01d6d09cdcb00677c0559954980fd370 (patch) | |
| tree | 46949f7a89e748dd8d9d79fcfa52a2705b9b34d2 /Library | |
| parent | faa5846a279cbabc06b29eb1e313023ab34cbbcc (diff) | |
| download | homebrew-21146eaa01d6d09cdcb00677c0559954980fd370.tar.bz2 | |
brew-bundle: add path support.
Closes #24384.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Contributions/cmd/brew-bundle.rb | 24 |
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 == '#' |
