diff options
| author | Markus Reiter | 2017-05-19 19:13:23 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-05-22 02:51:16 +0200 |
| commit | 9e821863d0ed97254bbae314b97af18d2f09cdfa (patch) | |
| tree | ec0f30fc60dab1b4d3de17a8fc163de6658913ea | |
| parent | 8f068a356dfe4769905d2487533b9e8124287098 (diff) | |
| download | brew-9e821863d0ed97254bbae314b97af18d2f09cdfa.tar.bz2 | |
Pass along `CLI::Binaries`.
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/artifact/binary.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/install.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/reinstall.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/uninstall.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/installer.rb | 16 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/artifact/binary_spec.rb | 30 |
6 files changed, 33 insertions, 28 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/binary.rb b/Library/Homebrew/cask/lib/hbc/artifact/binary.rb index 21d123ab9..7178c2af6 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/binary.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/binary.rb @@ -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? diff --git a/Library/Homebrew/cask/lib/hbc/cli/install.rb b/Library/Homebrew/cask/lib/hbc/cli/install.rb index 438f860c1..5b5ef82c4 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/install.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/install.rb @@ -19,10 +19,10 @@ module Hbc cask_tokens.each do |cask_token| begin cask = CaskLoader.load(cask_token) - Installer.new(cask, - force: force, - skip_cask_deps: skip_cask_deps, - require_sha: require_sha).install + Installer.new(cask, binaries: CLI.binaries?, + force: force, + skip_cask_deps: skip_cask_deps, + require_sha: require_sha).install count += 1 rescue CaskAlreadyInstalledError => e opoo e.message diff --git a/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb b/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb index c2ed8f462..662899d5f 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb @@ -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 diff --git a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb index 1ee3230ad..7fc40daaf 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb @@ -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? diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index f02f07806..d9addd604 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -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 diff --git a/Library/Homebrew/test/cask/artifact/binary_spec.rb b/Library/Homebrew/test/cask/artifact/binary_spec.rb index ee62e6439..f9b5f5b42 100644 --- a/Library/Homebrew/test/cask/artifact/binary_spec.rb +++ b/Library/Homebrew/test/cask/artifact/binary_spec.rb @@ -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 |
