| 
									
										
										
										
											2015-02-16 18:49:16 +00:00
										 |  |  | # DEPRECATED in favour of https://github.com/Homebrew/homebrew-brewdler | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2014-09-20 15:10:36 +01:00
										 |  |  | # 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 | 
					
						
							| 
									
										
										
										
											2015-02-16 18:49:16 +00:00
										 |  |  |     opoo <<-EOS.undent
 | 
					
						
							|  |  |  |       brew cleanup-installed is deprecated and will be removed soon! | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-18 14:10:27 +00:00
										 |  |  |       Please consider using the `brew brewdle dump` and `brew brewdle cleanup` | 
					
						
							| 
									
										
										
										
											2015-02-16 18:49:16 +00:00
										 |  |  |       commands from https://github.com/Homebrew/homebrew-brewdler | 
					
						
							|  |  |  |     EOS | 
					
						
							| 
									
										
										
										
											2014-09-20 15:10:36 +01:00
										 |  |  |     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? | 
					
						
							| 
									
										
										
										
											2015-01-11 10:12:44 +00:00
										 |  |  |     safe_system "brew", "uninstall", "--force", *uninstall_formulae | 
					
						
							| 
									
										
										
										
											2014-09-20 15:10:36 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | end |