diff options
| author | Jack Nagel | 2014-03-13 11:29:48 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2014-03-13 11:29:48 -0500 | 
| commit | fba5bf85b020300d29dcdedfdac1e3943b217941 (patch) | |
| tree | 5c1d1bdd315ee0da05ef3c98c0ef9fb6432255d8 /Library | |
| parent | d965bbba4753a92512f2cb136a29e90bf6199e1f (diff) | |
| download | brew-fba5bf85b020300d29dcdedfdac1e3943b217941.tar.bz2 | |
brew-unpack: use extend instead of reopening Formula
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Contributions/cmd/brew-unpack.rb | 27 | 
1 files changed, 12 insertions, 15 deletions
diff --git a/Library/Contributions/cmd/brew-unpack.rb b/Library/Contributions/cmd/brew-unpack.rb index a86c8b7ff..3a1db2dcf 100755 --- a/Library/Contributions/cmd/brew-unpack.rb +++ b/Library/Contributions/cmd/brew-unpack.rb @@ -23,24 +23,19 @@ module ScriptDataReader    end  end -# Need to tweak the Formula class slightly so that patching is option and `DATA` -# patches work correctly. -class Formula -  # Create a reference to the original Formula.patch method and then override -  # so that paching only happens if the user asks. -  alias do_patch patch +module UnpackPatch    def patch -    if ARGV.flag? '--patch' -      begin -        old_verbose = $VERBOSE -        $VERBOSE = nil -        Formula.const_set 'DATA', ScriptDataReader.load(path) -      ensure -        $VERBOSE = old_verbose -      end +    return unless ARGV.flag? "--patch" -      do_patch +    begin +      old_verbose = $VERBOSE +      $VERBOSE = nil +      Formula.const_set "DATA", ScriptDataReader.load(path) +    ensure +      $VERBOSE = old_verbose      end + +    super    end  end @@ -74,6 +69,8 @@ module Homebrew extend self      raise "Cannot write to #{unpack_dir}" unless unpack_dir.writable_real?      formulae.each do |f| +      f.extend(UnpackPatch) +        # Create a nice name for the stage folder.        stage_dir = unpack_dir + [f.name, f.version].join('-')  | 
