Pass along CLI::Binaries.
This commit is contained in:
parent
8f068a356d
commit
9e821863d0
@ -3,10 +3,6 @@ require "hbc/artifact/symlinked"
|
||||
module Hbc
|
||||
module Artifact
|
||||
class Binary < Symlinked
|
||||
def install_phase
|
||||
super if CLI.binaries?
|
||||
end
|
||||
|
||||
def link
|
||||
super
|
||||
return if source.executable?
|
||||
|
||||
@ -19,7 +19,7 @@ module Hbc
|
||||
cask_tokens.each do |cask_token|
|
||||
begin
|
||||
cask = CaskLoader.load(cask_token)
|
||||
Installer.new(cask,
|
||||
Installer.new(cask, binaries: CLI.binaries?,
|
||||
force: force,
|
||||
skip_cask_deps: skip_cask_deps,
|
||||
require_sha: require_sha).install
|
||||
|
||||
@ -8,6 +8,7 @@ module Hbc
|
||||
cask = CaskLoader.load(cask_token)
|
||||
|
||||
Installer.new(cask,
|
||||
binaries: CLI.binaries?,
|
||||
force: force,
|
||||
skip_cask_deps: skip_cask_deps,
|
||||
require_sha: require_sha).reinstall
|
||||
|
||||
@ -17,7 +17,7 @@ module Hbc
|
||||
cask = CaskLoader.load_from_file(cask.installed_caskfile) if cask.installed_caskfile.exist?
|
||||
end
|
||||
|
||||
Installer.new(cask, force: force).uninstall
|
||||
Installer.new(cask, binaries: CLI.binaries?, force: force).uninstall
|
||||
|
||||
next if (versions = cask.versions).empty?
|
||||
|
||||
|
||||
@ -18,15 +18,20 @@ module Hbc
|
||||
|
||||
PERSISTENT_METADATA_SUBDIRS = ["gpg"].freeze
|
||||
|
||||
def initialize(cask, command: SystemCommand, force: false, skip_cask_deps: false, require_sha: false)
|
||||
def initialize(cask, command: SystemCommand, force: false, skip_cask_deps: false, binaries: true, require_sha: false)
|
||||
@cask = cask
|
||||
@command = command
|
||||
@force = force
|
||||
@skip_cask_deps = skip_cask_deps
|
||||
@binaries = binaries
|
||||
@require_sha = require_sha
|
||||
@reinstall = false
|
||||
end
|
||||
|
||||
def binaries?
|
||||
@binaries
|
||||
end
|
||||
|
||||
def self.print_caveats(cask)
|
||||
odebug "Printing caveats"
|
||||
return if cask.caveats.empty?
|
||||
@ -108,7 +113,7 @@ module Hbc
|
||||
installed_cask = installed_caskfile.exist? ? CaskLoader.load_from_file(installed_caskfile) : @cask
|
||||
|
||||
# Always force uninstallation, ignore method parameter
|
||||
Installer.new(installed_cask, force: true).uninstall
|
||||
Installer.new(installed_cask, binaries: binaries?, force: true).uninstall
|
||||
end
|
||||
|
||||
def summary
|
||||
@ -162,6 +167,11 @@ module Hbc
|
||||
artifacts.each do |artifact|
|
||||
next unless artifact.respond_to?(:install_phase)
|
||||
odebug "Installing artifact of class #{artifact.class}"
|
||||
|
||||
if artifact.is_a?(Artifact::Binary)
|
||||
next unless binaries?
|
||||
end
|
||||
|
||||
artifact.install_phase
|
||||
already_installed_artifacts.unshift(artifact)
|
||||
end
|
||||
@ -254,7 +264,7 @@ module Hbc
|
||||
if dep.installed?
|
||||
puts "already installed"
|
||||
else
|
||||
Installer.new(dep, force: false, skip_cask_deps: true).install
|
||||
Installer.new(dep, force: false, binaries: binaries?, skip_cask_deps: true).install
|
||||
puts "done"
|
||||
end
|
||||
end
|
||||
|
||||
@ -16,6 +16,20 @@ describe Hbc::Artifact::Binary, :cask do
|
||||
FileUtils.rm expected_path if expected_path.exist?
|
||||
end
|
||||
|
||||
context "when --no-binaries is specified" do
|
||||
let(:cask) {
|
||||
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb")
|
||||
}
|
||||
|
||||
it "doesn't link the binary when --no-binaries is specified" do
|
||||
shutup do
|
||||
Hbc::Installer.new(cask, binaries: false).install
|
||||
end
|
||||
|
||||
expect(expected_path).not_to exist
|
||||
end
|
||||
end
|
||||
|
||||
it "links the binary to the proper directory" do
|
||||
shutup do
|
||||
Hbc::Artifact::Binary.new(cask).install_phase
|
||||
@ -70,22 +84,6 @@ describe Hbc::Artifact::Binary, :cask do
|
||||
expect(File.readlink(expected_path)).not_to eq("/tmp")
|
||||
end
|
||||
|
||||
it "respects --no-binaries flag" do
|
||||
begin
|
||||
Hbc::CLI.binaries = false
|
||||
|
||||
expect(Hbc::CLI).not_to be_binaries
|
||||
|
||||
shutup do
|
||||
Hbc::Artifact::Binary.new(cask).install_phase
|
||||
end
|
||||
|
||||
expect(expected_path.exist?).to be false
|
||||
ensure
|
||||
Hbc::CLI.binaries = true
|
||||
end
|
||||
end
|
||||
|
||||
it "creates parent directory if it doesn't exist" do
|
||||
FileUtils.rmdir Hbc.binarydir
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user