diff options
| author | Mike McQuaid | 2014-09-20 15:10:36 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2014-09-24 15:22:59 -0700 |
| commit | 0f38b19a8c3c22a55ae9a7d5106cf7f1b78144d0 (patch) | |
| tree | f0117d305d335f36c7527b604ac831539ff0de12 /Library/Homebrew/cmd | |
| parent | 19c4a1375893d8589c300a5d0f2d4743828b9c0a (diff) | |
| download | homebrew-0f38b19a8c3c22a55ae9a7d5106cf7f1b78144d0.tar.bz2 | |
brew-cleanup-installed: Rubify, make internal cmd.
Diffstat (limited to 'Library/Homebrew/cmd')
| -rwxr-xr-x | Library/Homebrew/cmd/cleanup-installed.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/cleanup-installed.rb b/Library/Homebrew/cmd/cleanup-installed.rb new file mode 100755 index 000000000..b79a380c1 --- /dev/null +++ b/Library/Homebrew/cmd/cleanup-installed.rb @@ -0,0 +1,20 @@ +# brew-cleanup-installed: uninstall all non-whitelisted Homebrew formulae. +# +# Useful for maintainers/testers who regularly install lots of formulae +# they don't actually use. +# +# Populate ~/.brew-cleanup-installed with the formulae you want to keep +# installed. All others will be uninstalled when brew-cleanup-installed is run. + +module Homebrew + def cleanup_installed + cleanup_file = Pathname.new "#{ENV["HOME"]}/.brew-cleanup-installed" + return unless cleanup_file.exist? + + kept_formulae = cleanup_file.read.lines.map(&:strip) + current_formulae = `brew list`.lines.map(&:strip) + uninstall_formulae = current_formulae - kept_formulae + return if uninstall_formulae.empty? + safe_system "brew", "uninstall", *uninstall_formulae + end +end |
