forked from plasma0713/brew-cask-upgrade-all
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brew-cask-upgrade-all.rb
executable file
·46 lines (33 loc) · 1011 Bytes
/
brew-cask-upgrade-all.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env ruby
puts "brew update:"
puts `brew update`
puts "brew upgrade:"
puts `brew upgrade`
puts "brew cask upgrade"
ignore_item = ['']#gpgtools']
FORCE_UPDATE = ARGV[0] == '-f'
`brew cask list`.split("\n").each do | item |
# ignore when specified it
next if ignore_item.include?(item)
# get most recently version number
current = `ls -t /usr/local/Caskroom/#{item}/`.split("\n").first.strip
# get latest version number
latest = `brew cask info #{item} | grep #{item} | grep #{item} | head -n 1`.split(': ')[1].strip
# output differences
puts "#{item}"
puts "latest : #{latest}"
puts "current : #{current}"
# verify
if latest != current || FORCE_UPDATE && latest == 'latest'
puts "#{item} updating.."
puts `brew cask uninstall --force #{item}`
puts `brew cask install #{item}`
puts "#{item} updated !!!"
end
puts " "
end
puts "brew cleanup:"
puts `brew cleanup`
puts "brew cask cleanup:"
puts `brew cask cleanup`
puts "\nall of done.\n"