Integrate upgrade with cask
This commit is contained in:
parent
f28f1f17e3
commit
210d22e819
@ -4,6 +4,9 @@ require "cli/parser"
|
|||||||
require "formula_installer"
|
require "formula_installer"
|
||||||
require "install"
|
require "install"
|
||||||
require "upgrade"
|
require "upgrade"
|
||||||
|
require "cask/cmd"
|
||||||
|
require "cask/utils"
|
||||||
|
require "cask/macos"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
@ -50,6 +53,8 @@ module Homebrew
|
|||||||
description: "Print install times for each formula at the end of the run."
|
description: "Print install times for each formula at the end of the run."
|
||||||
switch "-n", "--dry-run",
|
switch "-n", "--dry-run",
|
||||||
description: "Show what would be upgraded, but do not actually upgrade anything."
|
description: "Show what would be upgraded, but do not actually upgrade anything."
|
||||||
|
switch "--greedy",
|
||||||
|
description: "Upgrade casks with `auto_updates` or `version :latest`"
|
||||||
conflicts "--build-from-source", "--force-bottle"
|
conflicts "--build-from-source", "--force-bottle"
|
||||||
formula_options
|
formula_options
|
||||||
end
|
end
|
||||||
@ -66,14 +71,14 @@ module Homebrew
|
|||||||
outdated = Formula.installed.select do |f|
|
outdated = Formula.installed.select do |f|
|
||||||
f.outdated?(fetch_head: args.fetch_HEAD?)
|
f.outdated?(fetch_head: args.fetch_HEAD?)
|
||||||
end
|
end
|
||||||
|
casks = [] # Upgrade all installed casks
|
||||||
exit 0 if outdated.empty?
|
|
||||||
else
|
else
|
||||||
outdated = args.resolved_formulae.select do |f|
|
formulae, casks = args.resolved_formulae_casks
|
||||||
|
outdated, not_outdated = formulae.partition do |f|
|
||||||
f.outdated?(fetch_head: args.fetch_HEAD?)
|
f.outdated?(fetch_head: args.fetch_HEAD?)
|
||||||
end
|
end
|
||||||
|
|
||||||
(args.resolved_formulae - outdated).each do |f|
|
not_outdated.each do |f|
|
||||||
versions = f.installed_kegs.map(&:version)
|
versions = f.installed_kegs.map(&:version)
|
||||||
if versions.empty?
|
if versions.empty?
|
||||||
ofail "#{f.full_specified_name} not installed"
|
ofail "#{f.full_specified_name} not installed"
|
||||||
@ -82,9 +87,15 @@ module Homebrew
|
|||||||
opoo "#{f.full_specified_name} #{version} already installed"
|
opoo "#{f.full_specified_name} #{version} already installed"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return if outdated.empty?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
upgrade_outdated_formulae(outdated)
|
||||||
|
upgrade_outdated_casks(casks)
|
||||||
|
end
|
||||||
|
|
||||||
|
def upgrade_outdated_formulae(outdated)
|
||||||
|
return if outdated.empty?
|
||||||
|
|
||||||
pinned = outdated.select(&:pinned?)
|
pinned = outdated.select(&:pinned?)
|
||||||
outdated -= pinned
|
outdated -= pinned
|
||||||
formulae_to_install = outdated.map(&:latest_formula)
|
formulae_to_install = outdated.map(&:latest_formula)
|
||||||
@ -115,4 +126,12 @@ module Homebrew
|
|||||||
|
|
||||||
Homebrew.messages.display_messages
|
Homebrew.messages.display_messages
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def upgrade_outdated_casks(casks)
|
||||||
|
cask_upgrade = Cask::Cmd::Upgrade.new(casks)
|
||||||
|
cask_upgrade.force = args.force?
|
||||||
|
cask_upgrade.dry_run = args.dry_run?
|
||||||
|
cask_upgrade.greedy = args.greedy?
|
||||||
|
cask_upgrade.run
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user