From 1498f7a6577ef2ac0bcc8b7b9e0a6b404c2a9c2e Mon Sep 17 00:00:00 2001 From: Kwaku Yeboah-Antwi Date: Wed, 23 Mar 2016 23:22:45 +0100 Subject: [PATCH] autoupdate: add optional "--cleanup" flag Optionally toggle cleaning up automatically after upgrade. Closes #3. Signed-off-by: Dominyk Tiller --- README.md | 3 ++- cmd/brew-autoupdate.rb | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5fb53316d7a0..35e686cd717f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ An easy, convenient way to automatically update Homebrew. This script will run once every 24 hours, doing `brew update`. -`brew upgrade` can also be handled automatically but is an optional flag. +`brew upgrade` and `brew cleanup` can also be handled automatically but are optional flags. [![](http://imgs.xkcd.com/comics/update.png)](https://xkcd.com/1328/) @@ -21,6 +21,7 @@ Usage: --stop = Stop autoupdating, but retain plist & logs. --delete = Cancel the autoupdate, delete the plist and logs. --upgrade = Also automatically upgrade your packages. +--cleanup = Automatically cleanup old packages after upgrade. --version = Output this tool's current version. ``` diff --git a/cmd/brew-autoupdate.rb b/cmd/brew-autoupdate.rb index 75f3ae837607..65c2b9d3865d 100755 --- a/cmd/brew-autoupdate.rb +++ b/cmd/brew-autoupdate.rb @@ -14,18 +14,22 @@ def autoupdate --stop = Stop autoupdating, but retain plist & logs. --delete = Cancel the autoupdate, delete the plist and logs. --upgrade = Also automatically upgrade your packages. + --cleanup = Automatically cleanup old packages after upgrade. --version = Output this tool's current version. EOS end if ARGV.include? "--version" - puts "Version 1.1.0, July 2015" + puts "Version 1.1.1, February 2016" end if ARGV.include? "--start" auto_args = "#{HOMEBREW_PREFIX}/bin/brew update" # Spacing at start of line is deliberate. Don't undo. - auto_args << " && #{HOMEBREW_PREFIX}/bin/brew upgrade -v" if ARGV.include? "--upgrade" + if ARGV.include? "--upgrade" + auto_args << " && #{HOMEBREW_PREFIX}/bin/brew upgrade -v" + auto_args << " && #{HOMEBREW_PREFIX}/bin/brew cleanup -v" if ARGV.include? "--cleanup" + end file = <<-EOS.undent