Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Important Note] Move to https://github.com/DriftwoodJP/bcupgrade
#!/usr/bin/ruby
require 'readline'
# Create cask list
puts "\nCreate cask list...\n"
list = `brew cask list`
casks = list.delete(' (!)').split("\n")
puts "#{casks}\n"
# Check update cask
puts "\nCheck update cask...\n"
update_casks = []
casks.each do |cask|
info = `brew cask info #{cask}`
update_casks.push(cask) if info.include?('Not installed')
end
puts "#{update_casks}\n"
# Upgrade cask
if update_casks.any?
update_casks.each do |cask|
input = Readline.readline("\nUpgrade #{cask}? [y/n] ")
next unless input == 'y'
puts "remove #{cask}"
system "rm -rf /usr/local/Caskroom/#{cask}"
puts "install #{cask}"
system "brew cask install --force #{cask}"
end
else
puts "\nAlready up-to-date."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.