Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add cleanup command

* `brew cleanup foo` removes any unlinked foo kegs
* `brew cleanup` removes all unlinked kegs
  • Loading branch information...
commit ffd39835ec005a783fffdd5ef0bca2754f3117ad 1 parent ae3f858
Joshua Peek josh authored mxcl committed

Showing 2 changed files with 26 additions and 0 deletions. Show diff stats Hide diff stats

  1. +16 0 Library/Homebrew/brew.h.rb
  2. +10 0 bin/brew
16 Library/Homebrew/brew.h.rb
@@ -245,6 +245,22 @@ def issues_for_formula name
245 245 []
246 246 end
247 247
  248 +def cleanup name
  249 + require 'formula'
  250 +
  251 + f = Formula.factory name
  252 +
  253 + if f.prefix.parent.directory?
  254 + kids = f.prefix.parent.children
  255 + kids.each do |keg|
  256 + next if f.prefix == keg
  257 + print "Uninstalling #{keg}..."
  258 + FileUtils.rm_rf keg
  259 + puts
  260 + end
  261 + end
  262 +end
  263 +
248 264 def clean f
249 265 Cleaner.new f
250 266
10 bin/brew
@@ -207,6 +207,16 @@ begin
207 207 ARGV.named.each {|name| info name}
208 208 end
209 209
  210 + when 'cleanup'
  211 + if ARGV.named.empty?
  212 + require 'formula'
  213 + `ls #{HOMEBREW_CELLAR}`.each do |name|
  214 + cleanup name.strip
  215 + end
  216 + else
  217 + ARGV.named.each { |name| cleanup name}
  218 + end
  219 +
210 220 when 'install'
211 221 check_for_blacklisted_formula(ARGV.named)
212 222

0 comments on commit ffd3983

Please sign in to comment.
Something went wrong with that request. Please try again.