Output all upgradable casks before upgrading.

This commit is contained in:
Markus Reiter 2019-05-31 19:07:53 +02:00
parent a1a2b022e7
commit e2369fcde0
2 changed files with 14 additions and 10 deletions

View File

@ -34,22 +34,28 @@ module Cask
ohai "Casks with `auto_updates` or `version :latest` will not be upgraded" if args.empty? && !greedy? ohai "Casks with `auto_updates` or `version :latest` will not be upgraded" if args.empty? && !greedy?
oh1 "Upgrading #{outdated_casks.count} #{"outdated package".pluralize(outdated_casks.count)}:" oh1 "Upgrading #{outdated_casks.count} #{"outdated package".pluralize(outdated_casks.count)}:"
caught_exceptions = [] caught_exceptions = []
outdated_casks.each do |cask|
upgradable_casks = outdated_casks.map { |c| [CaskLoader.load(c.installed_caskfile), c] }
puts upgradable_casks
.map { |(old_cask, new_cask)| "#{new_cask.full_name} #{old_cask.version} -> #{new_cask.version}" }
.join(", ")
upgradable_casks.each do |(old_cask, new_cask)|
begin begin
old_cask = CaskLoader.load(cask.installed_caskfile) upgrade_cask(old_cask, new_cask)
puts "#{cask.full_name} #{old_cask.version} -> #{cask.version}"
upgrade_cask(old_cask)
rescue CaskError => e rescue CaskError => e
caught_exceptions << e caught_exceptions << e
next next
end end
end end
return if caught_exceptions.empty? return if caught_exceptions.empty?
raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1 raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1
raise caught_exceptions.first if caught_exceptions.count == 1 raise caught_exceptions.first if caught_exceptions.count == 1
end end
def upgrade_cask(old_cask) def upgrade_cask(old_cask, new_cask)
odebug "Started upgrade process for Cask #{old_cask}" odebug "Started upgrade process for Cask #{old_cask}"
old_config = old_cask.config old_config = old_cask.config
@ -59,8 +65,6 @@ module Cask
force: force?, force: force?,
upgrade: true) upgrade: true)
new_cask = CaskLoader.load(old_cask.token)
new_cask.config = Config.global.merge(old_config) new_cask.config = Config.global.merge(old_config)
new_cask_installer = new_cask_installer =
@ -76,10 +80,12 @@ module Cask
new_artifacts_installed = false new_artifacts_installed = false
begin begin
oh1 "Upgrading #{Formatter.identifier(old_cask)}"
# Start new Cask's installation steps # Start new Cask's installation steps
new_cask_installer.check_conflicts new_cask_installer.check_conflicts
puts new_cask_installer.caveats puts new_cask_installer.caveats if new_cask_installer.caveats
new_cask_installer.fetch new_cask_installer.fetch

View File

@ -407,8 +407,6 @@ module Cask
end end
def start_upgrade def start_upgrade
oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}"
uninstall_artifacts uninstall_artifacts
backup backup
end end