add casks install to cmd/install
This commit is contained in:
parent
a41a7c94d8
commit
b2156dc125
@ -2,8 +2,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/config"
|
||||
require "cask/cmd"
|
||||
require "cask/cmd/install"
|
||||
require "cask/installer"
|
||||
require "cask_dependent"
|
||||
require "missing_formula"
|
||||
require "formula_installer"
|
||||
require "development_tools"
|
||||
@ -127,8 +127,29 @@ module Homebrew
|
||||
formula_options
|
||||
[
|
||||
[:switch, "--cask", "--casks", { description: "Treat all named arguments as casks." }],
|
||||
*Cask::Cmd::AbstractCommand::OPTIONS.map(&:dup),
|
||||
*Cask::Cmd::Install::OPTIONS.map(&:dup),
|
||||
[:switch, "--[no-]binaries", {
|
||||
description: "Disable/enable linking of helper executables (default: enabled).",
|
||||
env: :cask_opts_binaries,
|
||||
}],
|
||||
[:switch, "--require-sha", {
|
||||
description: "Require all casks to have a checksum.",
|
||||
env: :cask_opts_require_sha,
|
||||
}],
|
||||
[:switch, "--[no-]quarantine", {
|
||||
description: "Disable/enable quarantining of downloads (default: enabled).",
|
||||
env: :cask_opts_quarantine,
|
||||
}],
|
||||
[:switch, "--adopt", {
|
||||
description: "Adopt existing artifacts in the destination that are identical to those being installed. " \
|
||||
"Cannot be combined with --force.",
|
||||
}],
|
||||
[:switch, "--skip-cask-deps", {
|
||||
description: "Skip installing cask dependencies.",
|
||||
}],
|
||||
[:switch, "--zap", {
|
||||
description: "For use with `brew reinstall --cask`. Remove all files associated with a cask. " \
|
||||
"*May remove files which are shared between applications.*",
|
||||
}],
|
||||
].each do |args|
|
||||
options = args.pop
|
||||
send(*args, **options)
|
||||
@ -183,18 +204,41 @@ module Homebrew
|
||||
end
|
||||
|
||||
if casks.any?
|
||||
Cask::Cmd::Install.install_casks(
|
||||
*casks,
|
||||
binaries: args.binaries?,
|
||||
verbose: args.verbose?,
|
||||
force: args.force?,
|
||||
adopt: args.adopt?,
|
||||
require_sha: args.require_sha?,
|
||||
skip_cask_deps: args.skip_cask_deps?,
|
||||
quarantine: args.quarantine?,
|
||||
quiet: args.quiet?,
|
||||
dry_run: args.dry_run?,
|
||||
)
|
||||
quarantine = args.quarantine?.nil? ? true : args.quarantine?
|
||||
|
||||
if args.dry_run?
|
||||
if (casks_to_install = casks.reject(&:installed?).presence)
|
||||
ohai "Would install #{::Utils.pluralize("cask", casks_to_install.count, include_count: true)}:"
|
||||
puts casks_to_install.map(&:full_name).join(" ")
|
||||
end
|
||||
casks.each do |cask|
|
||||
dep_names = CaskDependent.new(cask)
|
||||
.runtime_dependencies
|
||||
.reject(&:installed?)
|
||||
.map(&:to_formula)
|
||||
.map(&:name)
|
||||
next if dep_names.blank?
|
||||
|
||||
ohai "Would install #{::Utils.pluralize("dependenc", dep_names.count, plural: "ies", singular: "y",
|
||||
include_count: true)} for #{cask.full_name}:"
|
||||
puts dep_names.join(" ")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
require "cask/installer"
|
||||
|
||||
casks.each do |cask|
|
||||
Cask::Installer.new(cask,
|
||||
binaries: args.binaries?,
|
||||
verbose: args.verbose?,
|
||||
force: args.force?,
|
||||
adopt: args.adopt?,
|
||||
require_sha: args.require_sha?,
|
||||
skip_cask_deps: args.skip_cask_deps?,
|
||||
quarantine: quarantine,
|
||||
quiet: args.quiet?).install
|
||||
end
|
||||
end
|
||||
|
||||
# if the user's flags will prevent bottle only-installations when no
|
||||
|
||||
@ -53,7 +53,7 @@ describe Cask::Reinstall, :cask do
|
||||
end
|
||||
|
||||
it "allows reinstalling a Cask" do
|
||||
Cask::Cmd::Install.run("local-transmission")
|
||||
Cask::Installer.new(Cask::CaskLoader.load(cask_path("local-transmission"))).install
|
||||
|
||||
expect(Cask::CaskLoader.load(cask_path("local-transmission"))).to be_installed
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ describe Cask::Upgrade, :cask do
|
||||
end
|
||||
|
||||
before do
|
||||
installed.each { |cask| Cask::Cmd::Install.run(cask) }
|
||||
installed.each { |cask| Cask::Installer.new(Cask::CaskLoader.load(cask_path(cask))).install }
|
||||
|
||||
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
|
||||
end
|
||||
@ -191,7 +191,7 @@ describe Cask::Upgrade, :cask do
|
||||
end
|
||||
|
||||
before do
|
||||
installed.each { |cask| Cask::Cmd::Install.run(cask) }
|
||||
installed.each { |cask| Cask::Installer.new(Cask::CaskLoader.load(cask_path(cask))).install }
|
||||
|
||||
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
|
||||
end
|
||||
@ -358,7 +358,7 @@ describe Cask::Upgrade, :cask do
|
||||
end
|
||||
|
||||
before do
|
||||
installed.each { |cask| Cask::Cmd::Install.run(cask) }
|
||||
installed.each { |cask| Cask::Installer.new(Cask::CaskLoader.load(cask_path(cask))).install }
|
||||
|
||||
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
|
||||
end
|
||||
@ -414,7 +414,7 @@ describe Cask::Upgrade, :cask do
|
||||
end
|
||||
|
||||
before do
|
||||
installed.each { |cask| Cask::Cmd::Install.run(cask) }
|
||||
installed.each { |cask| Cask::Installer.new(Cask::CaskLoader.load(cask_path(cask))).install }
|
||||
|
||||
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user