diff options
| author | Max Howell | 2009-09-22 11:38:22 +0100 |
|---|---|---|
| committer | Max Howell | 2009-09-22 11:38:22 +0100 |
| commit | e60ea7bd2099873737c33c50bf65c2df908294b7 (patch) | |
| tree | 6965f9b65f7e644860d060bf2b63a8ca4c11ad05 /Library | |
| parent | 36bb590e826b0d690b61557de3bc6fd52205a4e2 (diff) | |
| download | brew-e60ea7bd2099873737c33c50bf65c2df908294b7.tar.bz2 | |
Clean up the empty dir cleaner a little
Using more Pathname methods.
Only show text if verbose mode is on, as is typical for the rest of our install output.
TODO: would be nice if we knew you were a dev and automatically enabled verbose mode perhaps.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/brew.h.rb | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index edfb15bed..0ec3e2c00 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -141,25 +141,19 @@ def clean f Cleaner.new f # Hunt for empty folders and nuke them unless they are - # protected in Formula.skip_clean? - + # protected by f.skip_clean? # We want post-order traversal, so put the dirs in a stack # and then pop them off later. - paths = Array.new - Find.find(f.prefix) do |path| - if FileTest.directory? path - paths.push path - end - next + paths = [] + f.prefix.find do |path| + paths << path if path.directory? end - + until paths.empty? do - path = paths.pop - next if f.skip_clean? Pathname.new(path) - entries = Dir.entries(path) - [".", ".."] - if entries.empty? - puts "Removing empty #{path}" - Dir.rmdir path + d = paths.pop + if d.children.empty? and not f.skip_clean? d + puts "rmdir: #{d} (empty)" if ARGV.verbose? + d.rmdir end end end |
