add casks install to cmd/install
This commit is contained in:
parent
a41a7c94d8
commit
b2156dc125
@ -2,8 +2,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cask/config"
|
require "cask/config"
|
||||||
require "cask/cmd"
|
require "cask/installer"
|
||||||
require "cask/cmd/install"
|
require "cask_dependent"
|
||||||
require "missing_formula"
|
require "missing_formula"
|
||||||
require "formula_installer"
|
require "formula_installer"
|
||||||
require "development_tools"
|
require "development_tools"
|
||||||
@ -127,8 +127,29 @@ module Homebrew
|
|||||||
formula_options
|
formula_options
|
||||||
[
|
[
|
||||||
[:switch, "--cask", "--casks", { description: "Treat all named arguments as casks." }],
|
[:switch, "--cask", "--casks", { description: "Treat all named arguments as casks." }],
|
||||||
*Cask::Cmd::AbstractCommand::OPTIONS.map(&:dup),
|
[:switch, "--[no-]binaries", {
|
||||||
*Cask::Cmd::Install::OPTIONS.map(&:dup),
|
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|
|
].each do |args|
|
||||||
options = args.pop
|
options = args.pop
|
||||||
send(*args, **options)
|
send(*args, **options)
|
||||||
@ -183,18 +204,41 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if casks.any?
|
if casks.any?
|
||||||
Cask::Cmd::Install.install_casks(
|
quarantine = args.quarantine?.nil? ? true : args.quarantine?
|
||||||
*casks,
|
|
||||||
binaries: args.binaries?,
|
if args.dry_run?
|
||||||
verbose: args.verbose?,
|
if (casks_to_install = casks.reject(&:installed?).presence)
|
||||||
force: args.force?,
|
ohai "Would install #{::Utils.pluralize("cask", casks_to_install.count, include_count: true)}:"
|
||||||
adopt: args.adopt?,
|
puts casks_to_install.map(&:full_name).join(" ")
|
||||||
require_sha: args.require_sha?,
|
end
|
||||||
skip_cask_deps: args.skip_cask_deps?,
|
casks.each do |cask|
|
||||||
quarantine: args.quarantine?,
|
dep_names = CaskDependent.new(cask)
|
||||||
quiet: args.quiet?,
|
.runtime_dependencies
|
||||||
dry_run: args.dry_run?,
|
.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
|
end
|
||||||
|
|
||||||
# if the user's flags will prevent bottle only-installations when no
|
# if the user's flags will prevent bottle only-installations when no
|
||||||
|
|||||||
@ -53,7 +53,7 @@ describe Cask::Reinstall, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "allows reinstalling a Cask" do
|
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
|
expect(Cask::CaskLoader.load(cask_path("local-transmission"))).to be_installed
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ describe Cask::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
before do
|
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)
|
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
|
||||||
end
|
end
|
||||||
@ -191,7 +191,7 @@ describe Cask::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
before do
|
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)
|
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
|
||||||
end
|
end
|
||||||
@ -358,7 +358,7 @@ describe Cask::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
before do
|
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)
|
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
|
||||||
end
|
end
|
||||||
@ -414,7 +414,7 @@ describe Cask::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
before do
|
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)
|
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user