diff options
| author | Mike McQuaid | 2013-11-17 09:41:41 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2013-11-17 09:42:18 +0000 |
| commit | c3b32c018928a4ba38698f2d013e4ea75bbd0acf (patch) | |
| tree | 9ce43267693582e25cce4c6cf03423377ce5e03f /Library | |
| parent | de12583bb81a2752951d3bba633a8b13094069c3 (diff) | |
| download | brew-c3b32c018928a4ba38698f2d013e4ea75bbd0acf.tar.bz2 | |
brew-bundle: cleanup path handling.
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Contributions/cmd/brew-bundle.rb | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/Library/Contributions/cmd/brew-bundle.rb b/Library/Contributions/cmd/brew-bundle.rb index 2924e1093..a467f1c8f 100755 --- a/Library/Contributions/cmd/brew-bundle.rb +++ b/Library/Contributions/cmd/brew-bundle.rb @@ -4,28 +4,31 @@ # # 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 # 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`. -if ARGV.empty? then - path = 'brewfile' -else - path = ARGV[0] - if File.directory? path then - path = path + '/brewfile' - end +path = 'Brewfile' +error = ' in current directory' + +if ARGV.first + if File.directory? ARGV.first + path = "#{ARGV.first}/#{path}" + error = " in '#{ARGV.first}'" + else + path = ARGV.first + error = " at '#{ARGV.first}'" + end end -raise "No such Brewfile: #{path}" unless File.exist? path +raise "Cannot find Brewfile#{error}" unless File.exist? path File.readlines(path).each do |line| command = line.chomp |
