Skip to content

Commit

Permalink
autoupdate: add optional "--cleanup" flag
Browse files Browse the repository at this point in the history
Optionally toggle cleaning up automatically after upgrade.

Closes Homebrew#3.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
  • Loading branch information
Killeroid authored and DomT4 committed May 23, 2016
1 parent b2e2a1d commit 1498f7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand All @@ -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.
```

Expand Down
8 changes: 6 additions & 2 deletions cmd/brew-autoupdate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?xml version="1.0" encoding="UTF-8"?>
Expand Down

0 comments on commit 1498f7a

Please sign in to comment.