mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Save config file for casks.
This commit is contained in:
parent
058bd4bf7c
commit
1e1ce1c471
@ -11,7 +11,7 @@ module Cask
|
|||||||
extend Searchable
|
extend Searchable
|
||||||
include Metadata
|
include Metadata
|
||||||
|
|
||||||
attr_reader :token, :sourcefile_path, :config
|
attr_reader :token, :sourcefile_path
|
||||||
|
|
||||||
def self.each
|
def self.each
|
||||||
return to_enum unless block_given?
|
return to_enum unless block_given?
|
||||||
@ -31,7 +31,7 @@ module Cask
|
|||||||
@tap
|
@tap
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(token, sourcefile_path: nil, tap: nil, config: Config.global, &block)
|
def initialize(token, sourcefile_path: nil, tap: nil, config: nil, &block)
|
||||||
@token = token
|
@token = token
|
||||||
@sourcefile_path = sourcefile_path
|
@sourcefile_path = sourcefile_path
|
||||||
@tap = tap
|
@tap = tap
|
||||||
@ -77,6 +77,14 @@ module Cask
|
|||||||
metadata_master_container_path.join(*installed_version, "Casks", "#{token}.rb")
|
metadata_master_container_path.join(*installed_version, "Casks", "#{token}.rb")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def config
|
||||||
|
@config ||= Config.for_cask(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
def config_path
|
||||||
|
metadata_master_container_path/"dirs.json"
|
||||||
|
end
|
||||||
|
|
||||||
def outdated?(greedy = false)
|
def outdated?(greedy = false)
|
||||||
!outdated_versions(greedy).empty?
|
!outdated_versions(greedy).empty?
|
||||||
end
|
end
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
|
require "json"
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
class Config
|
class Config < DelegateClass(Hash)
|
||||||
def self.global
|
DEFAULT_DIRS = {
|
||||||
@global ||= new
|
|
||||||
end
|
|
||||||
|
|
||||||
attr_reader :binarydir
|
|
||||||
|
|
||||||
def initialize(
|
|
||||||
appdir: "/Applications",
|
appdir: "/Applications",
|
||||||
prefpanedir: "~/Library/PreferencePanes",
|
prefpanedir: "~/Library/PreferencePanes",
|
||||||
qlplugindir: "~/Library/QuickLook",
|
qlplugindir: "~/Library/QuickLook",
|
||||||
@ -19,47 +15,51 @@ module Cask
|
|||||||
audio_unit_plugindir: "~/Library/Audio/Plug-Ins/Components",
|
audio_unit_plugindir: "~/Library/Audio/Plug-Ins/Components",
|
||||||
vst_plugindir: "~/Library/Audio/Plug-Ins/VST",
|
vst_plugindir: "~/Library/Audio/Plug-Ins/VST",
|
||||||
vst3_plugindir: "~/Library/Audio/Plug-Ins/VST3",
|
vst3_plugindir: "~/Library/Audio/Plug-Ins/VST3",
|
||||||
screen_saverdir: "~/Library/Screen Savers"
|
screen_saverdir: "~/Library/Screen Savers",
|
||||||
)
|
}.freeze
|
||||||
|
|
||||||
self.appdir = appdir
|
def self.global
|
||||||
self.prefpanedir = prefpanedir
|
@global ||= new
|
||||||
self.qlplugindir = qlplugindir
|
|
||||||
self.dictionarydir = dictionarydir
|
|
||||||
self.fontdir = fontdir
|
|
||||||
self.colorpickerdir = colorpickerdir
|
|
||||||
self.servicedir = servicedir
|
|
||||||
self.input_methoddir = input_methoddir
|
|
||||||
self.internet_plugindir = internet_plugindir
|
|
||||||
self.audio_unit_plugindir = audio_unit_plugindir
|
|
||||||
self.vst_plugindir = vst_plugindir
|
|
||||||
self.vst3_plugindir = vst3_plugindir
|
|
||||||
self.screen_saverdir = screen_saverdir
|
|
||||||
|
|
||||||
# `binarydir` is not customisable.
|
|
||||||
@binarydir = HOMEBREW_PREFIX/"bin"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
[
|
def self.for_cask(cask)
|
||||||
:appdir,
|
if cask.config_path.exist?
|
||||||
:prefpanedir,
|
from_file(cask.config_path)
|
||||||
:qlplugindir,
|
else
|
||||||
:dictionarydir,
|
global
|
||||||
:fontdir,
|
end
|
||||||
:colorpickerdir,
|
end
|
||||||
:servicedir,
|
|
||||||
:input_methoddir,
|
def self.from_file(path)
|
||||||
:internet_plugindir,
|
config = begin
|
||||||
:audio_unit_plugindir,
|
JSON.parse(File.read(path))
|
||||||
:vst_plugindir,
|
rescue JSON::ParserError => e
|
||||||
:vst3_plugindir,
|
raise e, "Cannot parse #{path}: #{e}", e.backtrace
|
||||||
:screen_saverdir,
|
end
|
||||||
].each do |dir|
|
|
||||||
attr_reader dir
|
new(Hash[config.map { |k, v| [k.to_sym, v] }])
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(**dirs)
|
||||||
|
super(Hash[DEFAULT_DIRS.map { |(k, v)| [k, Pathname(dirs.fetch(k, v)).expand_path] }])
|
||||||
|
end
|
||||||
|
|
||||||
|
def binarydir
|
||||||
|
@binarydir ||= HOMEBREW_PREFIX/"bin"
|
||||||
|
end
|
||||||
|
|
||||||
|
DEFAULT_DIRS.keys.each do |dir|
|
||||||
|
define_method(dir) do
|
||||||
|
self[dir]
|
||||||
|
end
|
||||||
|
|
||||||
define_method(:"#{dir}=") do |path|
|
define_method(:"#{dir}=") do |path|
|
||||||
instance_variable_set(:"@#{dir}", Pathname(path).expand_path)
|
self[dir] = Pathname(path).expand_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def write(path)
|
||||||
|
path.atomic_write(to_json)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
attr_predicate :binaries?, :force?, :skip_cask_deps?, :require_sha?,
|
attr_predicate :binaries?, :force?, :skip_cask_deps?, :require_sha?,
|
||||||
:upgrade?, :verbose?, :installed_as_dependency?,
|
:reinstall?, :upgrade?, :verbose?, :installed_as_dependency?,
|
||||||
:quarantine?
|
:quarantine?
|
||||||
|
|
||||||
def self.print_caveats(cask)
|
def self.print_caveats(cask)
|
||||||
@ -79,7 +79,7 @@ module Cask
|
|||||||
def install
|
def install
|
||||||
odebug "Cask::Installer#install"
|
odebug "Cask::Installer#install"
|
||||||
|
|
||||||
if @cask.installed? && !force? && !@reinstall && !upgrade?
|
if @cask.installed? && !force? && !reinstall? && !upgrade?
|
||||||
raise CaskAlreadyInstalledError, @cask
|
raise CaskAlreadyInstalledError, @cask
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ module Cask
|
|||||||
|
|
||||||
print_caveats
|
print_caveats
|
||||||
fetch
|
fetch
|
||||||
uninstall_existing_cask if @reinstall
|
uninstall_existing_cask if reinstall?
|
||||||
|
|
||||||
oh1 "Installing Cask #{Formatter.identifier(@cask)}"
|
oh1 "Installing Cask #{Formatter.identifier(@cask)}"
|
||||||
opoo "macOS's Gatekeeper has been disabled for this Cask" unless quarantine?
|
opoo "macOS's Gatekeeper has been disabled for this Cask" unless quarantine?
|
||||||
@ -209,6 +209,8 @@ module Cask
|
|||||||
artifact.install_phase(command: @command, verbose: verbose?, force: force?)
|
artifact.install_phase(command: @command, verbose: verbose?, force: force?)
|
||||||
already_installed_artifacts.unshift(artifact)
|
already_installed_artifacts.unshift(artifact)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
save_config_file
|
||||||
rescue => e
|
rescue => e
|
||||||
begin
|
begin
|
||||||
already_installed_artifacts.each do |artifact|
|
already_installed_artifacts.each do |artifact|
|
||||||
@ -382,13 +384,23 @@ module Cask
|
|||||||
old_savedir&.rmtree
|
old_savedir&.rmtree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def save_config_file
|
||||||
|
@cask.config.write(@cask.config_path)
|
||||||
|
end
|
||||||
|
|
||||||
def uninstall
|
def uninstall
|
||||||
oh1 "Uninstalling Cask #{Formatter.identifier(@cask)}"
|
oh1 "Uninstalling Cask #{Formatter.identifier(@cask)}"
|
||||||
uninstall_artifacts(clear: true)
|
uninstall_artifacts(clear: true)
|
||||||
|
remove_config_file unless reinstall? || upgrade?
|
||||||
purge_versioned_files
|
purge_versioned_files
|
||||||
purge_caskroom_path if force?
|
purge_caskroom_path if force?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_config_file
|
||||||
|
FileUtils.rm_f @cask.config_path
|
||||||
|
@cask.config_path.parent.rmdir_if_possible
|
||||||
|
end
|
||||||
|
|
||||||
def start_upgrade
|
def start_upgrade
|
||||||
oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}"
|
oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}"
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
}
|
}
|
||||||
|
|
||||||
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
||||||
let(:target_path) { Cask::Config.global.appdir.join("AnotherName.app") }
|
let(:target_path) { cask.config.appdir.join("AnotherName.app") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
InstallHelper.install_without_artifacts(cask)
|
InstallHelper.install_without_artifacts(cask)
|
||||||
@ -58,7 +58,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
expect(target_path).to be_a_directory
|
expect(target_path).to be_a_directory
|
||||||
expect(source_path).not_to exist
|
expect(source_path).not_to exist
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine Deluxe.app")).not_to exist
|
expect(cask.config.appdir.join("Caffeine Deluxe.app")).not_to exist
|
||||||
expect(cask.staged_path.join("Caffeine Deluxe.app")).to be_a_directory
|
expect(cask.staged_path.join("Caffeine Deluxe.app")).to be_a_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
let(:app) { cask.artifacts.find { |a| a.is_a?(described_class) } }
|
let(:app) { cask.artifacts.find { |a| a.is_a?(described_class) } }
|
||||||
|
|
||||||
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
||||||
let(:target_path) { Cask::Config.global.appdir.join("Caffeine.app") }
|
let(:target_path) { cask.config.appdir.join("Caffeine.app") }
|
||||||
|
|
||||||
let(:install_phase) { app.install_phase(command: command, force: force) }
|
let(:install_phase) { app.install_phase(command: command, force: force) }
|
||||||
let(:uninstall_phase) { app.uninstall_phase(command: command, force: force) }
|
let(:uninstall_phase) { app.uninstall_phase(command: command, force: force) }
|
||||||
@ -53,7 +53,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
expect(target_path).to be_a_directory
|
expect(target_path).to be_a_directory
|
||||||
expect(source_path).not_to exist
|
expect(source_path).not_to exist
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine Deluxe.app")).not_to exist
|
expect(cask.config.appdir.join("Caffeine Deluxe.app")).not_to exist
|
||||||
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
|
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ describe Cask::Artifact::Binary, :cask do
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
let(:artifacts) { cask.artifacts.select { |a| a.is_a?(described_class) } }
|
let(:artifacts) { cask.artifacts.select { |a| a.is_a?(described_class) } }
|
||||||
let(:expected_path) { Cask::Config.global.binarydir.join("binary") }
|
let(:expected_path) { cask.config.binarydir.join("binary") }
|
||||||
|
|
||||||
after do
|
after do
|
||||||
FileUtils.rm expected_path if expected_path.exist?
|
FileUtils.rm expected_path if expected_path.exist?
|
||||||
@ -38,7 +38,7 @@ describe Cask::Artifact::Binary, :cask do
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
let(:expected_path) { Cask::Config.global.binarydir.join("naked_non_executable") }
|
let(:expected_path) { cask.config.binarydir.join("naked_non_executable") }
|
||||||
|
|
||||||
it "makes the binary executable" do
|
it "makes the binary executable" do
|
||||||
expect(FileUtils).to receive(:chmod)
|
expect(FileUtils).to receive(:chmod)
|
||||||
|
@ -10,7 +10,7 @@ describe Cask::Artifact::Artifact, :cask do
|
|||||||
}
|
}
|
||||||
|
|
||||||
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
||||||
let(:target_path) { Cask::Config.global.appdir.join("Caffeine.app") }
|
let(:target_path) { cask.config.appdir.join("Caffeine.app") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
InstallHelper.install_without_artifacts(cask)
|
InstallHelper.install_without_artifacts(cask)
|
||||||
|
@ -9,7 +9,7 @@ describe Cask::Artifact::Suite, :cask do
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
let(:target_path) { Cask::Config.global.appdir.join("Caffeine") }
|
let(:target_path) { cask.config.appdir.join("Caffeine") }
|
||||||
let(:source_path) { cask.staged_path.join("Caffeine") }
|
let(:source_path) { cask.staged_path.join("Caffeine") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -11,10 +11,10 @@ describe Cask::Artifact::App, :cask do
|
|||||||
}
|
}
|
||||||
|
|
||||||
let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") }
|
let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") }
|
||||||
let(:target_path_mini) { Cask::Config.global.appdir.join("Caffeine Mini.app") }
|
let(:target_path_mini) { cask.config.appdir.join("Caffeine Mini.app") }
|
||||||
|
|
||||||
let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") }
|
let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") }
|
||||||
let(:target_path_pro) { Cask::Config.global.appdir.join("Caffeine Pro.app") }
|
let(:target_path_pro) { cask.config.appdir.join("Caffeine Pro.app") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
InstallHelper.install_without_artifacts(cask)
|
InstallHelper.install_without_artifacts(cask)
|
||||||
@ -52,7 +52,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
expect(target_path_mini).to be_a_directory
|
expect(target_path_mini).to be_a_directory
|
||||||
expect(source_path_mini).not_to exist
|
expect(source_path_mini).not_to exist
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine Deluxe.app")).not_to exist
|
expect(cask.config.appdir.join("Caffeine Deluxe.app")).not_to exist
|
||||||
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
|
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,11 +21,12 @@ describe Cask::Cmd::Install, :cask do
|
|||||||
|
|
||||||
it "allows staging and activation of multiple Casks at once" do
|
it "allows staging and activation of multiple Casks at once" do
|
||||||
described_class.run("local-transmission", "local-caffeine")
|
described_class.run("local-transmission", "local-caffeine")
|
||||||
|
transmission = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
expect(Cask::CaskLoader.load(cask_path("local-transmission"))).to be_installed
|
caffeine = Cask::CaskLoader.load(cask_path("local-caffeine"))
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).to be_a_directory
|
expect(transmission).to be_installed
|
||||||
expect(Cask::CaskLoader.load(cask_path("local-caffeine"))).to be_installed
|
expect(transmission.config.appdir.join("Transmission.app")).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine.app")).to be_a_directory
|
expect(caffeine).to be_installed
|
||||||
|
expect(caffeine.config.appdir.join("Caffeine.app")).to be_a_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
it "skips double install (without nuking existing installation)" do
|
it "skips double install (without nuking existing installation)" do
|
||||||
|
@ -80,9 +80,9 @@ describe Cask::Cmd::List, :cask do
|
|||||||
described_class.run("local-transmission", "local-caffeine")
|
described_class.run("local-transmission", "local-caffeine")
|
||||||
}.to output(<<~EOS).to_stdout
|
}.to output(<<~EOS).to_stdout
|
||||||
==> Apps
|
==> Apps
|
||||||
#{Cask::Config.global.appdir.join("Transmission.app")} (#{Cask::Config.global.appdir.join("Transmission.app").abv})
|
#{transmission.config.appdir.join("Transmission.app")} (#{transmission.config.appdir.join("Transmission.app").abv})
|
||||||
==> Apps
|
==> Apps
|
||||||
Missing App: #{Cask::Config.global.appdir.join("Caffeine.app")}
|
Missing App: #{caffeine.config.appdir.join("Caffeine.app")}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -51,9 +51,9 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
described_class.run("local-caffeine", "local-transmission")
|
described_class.run("local-caffeine", "local-transmission")
|
||||||
|
|
||||||
expect(caffeine).not_to be_installed
|
expect(caffeine).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to exist
|
expect(caffeine.config.appdir.join("Transmission.app")).not_to exist
|
||||||
expect(transmission).not_to be_installed
|
expect(transmission).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine.app")).not_to exist
|
expect(transmission.config.appdir.join("Caffeine.app")).not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls `uninstall` before removing artifacts" do
|
it "calls `uninstall` before removing artifacts" do
|
||||||
@ -69,7 +69,7 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
}.not_to raise_error
|
}.not_to raise_error
|
||||||
|
|
||||||
expect(cask).not_to be_installed
|
expect(cask).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("MyFancyApp.app")).not_to exist
|
expect(cask.config.appdir.join("MyFancyApp.app")).not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can uninstall Casks when the uninstall script is missing, but only when using `--force`" do
|
it "can uninstall Casks when the uninstall script is missing, but only when using `--force`" do
|
||||||
@ -79,7 +79,7 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
|
|
||||||
expect(cask).to be_installed
|
expect(cask).to be_installed
|
||||||
|
|
||||||
Cask::Config.global.appdir.join("MyFancyApp.app").rmtree
|
cask.config.appdir.join("MyFancyApp.app").rmtree
|
||||||
|
|
||||||
expect { described_class.run("with-uninstall-script-app") }
|
expect { described_class.run("with-uninstall-script-app") }
|
||||||
.to raise_error(Cask::CaskError, /uninstall script .* does not exist/)
|
.to raise_error(Cask::CaskError, /uninstall script .* does not exist/)
|
||||||
|
@ -147,7 +147,7 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
it 'does not include the Casks with "auto_updates true" when the version did not change' do
|
it 'does not include the Casks with "auto_updates true" when the version did not change' do
|
||||||
cask = Cask::CaskLoader.load("auto-updates")
|
cask = Cask::CaskLoader.load("auto-updates")
|
||||||
cask_path = Cask::Config.global.appdir.join("MyFancyApp.app")
|
cask_path = cask.config.appdir.join("MyFancyApp.app")
|
||||||
|
|
||||||
expect(cask).to be_installed
|
expect(cask).to be_installed
|
||||||
expect(cask_path).to be_a_directory
|
expect(cask_path).to be_a_directory
|
||||||
@ -188,7 +188,7 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
it "restores the old Cask if the upgrade failed" do
|
it "restores the old Cask if the upgrade failed" do
|
||||||
will_fail_if_upgraded = Cask::CaskLoader.load("will-fail-if-upgraded")
|
will_fail_if_upgraded = Cask::CaskLoader.load("will-fail-if-upgraded")
|
||||||
will_fail_if_upgraded_path = Cask::Config.global.appdir.join("container")
|
will_fail_if_upgraded_path = will_fail_if_upgraded.config.appdir.join("container")
|
||||||
|
|
||||||
expect(will_fail_if_upgraded).to be_installed
|
expect(will_fail_if_upgraded).to be_installed
|
||||||
expect(will_fail_if_upgraded_path).to be_a_file
|
expect(will_fail_if_upgraded_path).to be_a_file
|
||||||
@ -206,7 +206,7 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
it "does not restore the old Cask if the upgrade failed pre-install" do
|
it "does not restore the old Cask if the upgrade failed pre-install" do
|
||||||
bad_checksum = Cask::CaskLoader.load("bad-checksum")
|
bad_checksum = Cask::CaskLoader.load("bad-checksum")
|
||||||
bad_checksum_path = Cask::Config.global.appdir.join("Caffeine.app")
|
bad_checksum_path = bad_checksum.config.appdir.join("Caffeine.app")
|
||||||
|
|
||||||
expect(bad_checksum).to be_installed
|
expect(bad_checksum).to be_installed
|
||||||
expect(bad_checksum_path).to be_a_directory
|
expect(bad_checksum_path).to be_a_directory
|
||||||
|
@ -23,8 +23,8 @@ describe Cask::Cmd::Zap, :cask do
|
|||||||
described_class.run("local-caffeine", "local-transmission")
|
described_class.run("local-caffeine", "local-transmission")
|
||||||
|
|
||||||
expect(caffeine).not_to be_installed
|
expect(caffeine).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine.app")).not_to be_a_symlink
|
expect(caffeine.config.appdir.join("Caffeine.app")).not_to be_a_symlink
|
||||||
expect(transmission).not_to be_installed
|
expect(transmission).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to be_a_symlink
|
expect(transmission.config.appdir.join("Transmission.app")).not_to be_a_symlink
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -468,7 +468,7 @@ describe Cask::DSL, :cask do
|
|||||||
let(:token) { "appdir-interpolation" }
|
let(:token) { "appdir-interpolation" }
|
||||||
|
|
||||||
it "is allowed" do
|
it "is allowed" do
|
||||||
expect(cask.artifacts.first.source).to eq(Cask::Config.global.appdir/"some/path")
|
expect(cask.artifacts.first.source).to eq(cask.config.appdir/"some/path")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(caffeine).install
|
Cask::Installer.new(caffeine).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("local-caffeine", caffeine.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("local-caffeine", caffeine.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine.app")).to be_a_directory
|
expect(caffeine.config.appdir.join("Caffeine.app")).to be_a_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with dmg-based Casks" do
|
it "works with dmg-based Casks" do
|
||||||
@ -19,7 +19,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-dmg", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-dmg", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with tar-gz-based Casks" do
|
it "works with tar-gz-based Casks" do
|
||||||
@ -28,7 +28,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-tar-gz", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-tar-gz", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with xar-based Casks" do
|
it "works with xar-based Casks" do
|
||||||
@ -37,7 +37,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-xar", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-xar", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with pure bzip2-based Casks" do
|
it "works with pure bzip2-based Casks" do
|
||||||
@ -46,7 +46,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-bzip2", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-bzip2", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with pure gzip-based Casks" do
|
it "works with pure gzip-based Casks" do
|
||||||
@ -55,7 +55,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-gzip", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-gzip", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "blows up on a bad checksum" do
|
it "blows up on a bad checksum" do
|
||||||
|
@ -11,13 +11,11 @@ describe Cask::Quarantine, :cask do
|
|||||||
it "quarantines a nice fresh Cask" do
|
it "quarantines a nice fresh Cask" do
|
||||||
Cask::Cmd::Install.run("local-transmission")
|
Cask::Cmd::Install.run("local-transmission")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(
|
expect(cask).to be_installed
|
||||||
Cask::Config.global.appdir.join("Transmission.app"),
|
|
||||||
).to be_quarantined
|
expect(cask.config.appdir.join("Transmission.app")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines Cask fetches" do
|
it "quarantines Cask fetches" do
|
||||||
@ -42,83 +40,81 @@ describe Cask::Quarantine, :cask do
|
|||||||
|
|
||||||
Cask::Cmd::Install.run("local-transmission")
|
Cask::Cmd::Install.run("local-transmission")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("Transmission.app")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines dmg-based Casks" do
|
it "quarantines dmg-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-dmg")
|
Cask::Cmd::Install.run("container-dmg")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-dmg"))
|
||||||
Cask::CaskLoader.load(cask_path("container-dmg")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines tar-gz-based Casks" do
|
it "quarantines tar-gz-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-tar-gz")
|
Cask::Cmd::Install.run("container-tar-gz")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-tar-gz"))
|
||||||
Cask::CaskLoader.load(cask_path("container-tar-gz")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines xar-based Casks" do
|
it "quarantines xar-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-xar")
|
Cask::Cmd::Install.run("container-xar")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-xar"))
|
||||||
Cask::CaskLoader.load(cask_path("container-xar")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines pure bzip2-based Casks" do
|
it "quarantines pure bzip2-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-bzip2")
|
Cask::Cmd::Install.run("container-bzip2")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-bzip2"))
|
||||||
Cask::CaskLoader.load(cask_path("container-bzip2")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines pure gzip-based Casks" do
|
it "quarantines pure gzip-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-gzip")
|
Cask::Cmd::Install.run("container-gzip")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-gzip"))
|
||||||
Cask::CaskLoader.load(cask_path("container-gzip")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines the pkg in naked-pkg-based Casks" do
|
it "quarantines the pkg in naked-pkg-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-pkg")
|
Cask::Cmd::Install.run("container-pkg")
|
||||||
|
|
||||||
naked_pkg = Cask::CaskLoader.load(cask_path("container-pkg"))
|
cask = Cask::CaskLoader.load(cask_path("container-pkg"))
|
||||||
|
|
||||||
expect(naked_pkg).to be_installed
|
expect(cask).to be_installed
|
||||||
|
|
||||||
expect(
|
expect(cask.staged_path/"container.pkg").to be_quarantined
|
||||||
Cask::Caskroom.path.join("container-pkg", naked_pkg.version, "container.pkg"),
|
|
||||||
).to be_quarantined
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines a nested container" do
|
it "quarantines a nested container" do
|
||||||
Cask::Cmd::Install.run("nested-app")
|
Cask::Cmd::Install.run("nested-app")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("nested-app"))
|
||||||
Cask::CaskLoader.load(cask_path("nested-app")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("MyNestedApp.app")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("MyNestedApp.app")).to be_quarantined
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -126,11 +122,11 @@ describe Cask::Quarantine, :cask do
|
|||||||
it "does not quarantine even a nice, fresh Cask" do
|
it "does not quarantine even a nice, fresh Cask" do
|
||||||
Cask::Cmd::Install.run("local-transmission", "--no-quarantine")
|
Cask::Cmd::Install.run("local-transmission", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("Transmission.app")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine Cask fetches" do
|
it "does not quarantine Cask fetches" do
|
||||||
@ -155,61 +151,61 @@ describe Cask::Quarantine, :cask do
|
|||||||
|
|
||||||
Cask::Cmd::Install.run("local-transmission", "--no-quarantine")
|
Cask::Cmd::Install.run("local-transmission", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("Transmission.app")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine dmg-based Casks" do
|
it "does not quarantine dmg-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-dmg", "--no-quarantine")
|
Cask::Cmd::Install.run("container-dmg", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-dmg"))
|
||||||
Cask::CaskLoader.load(cask_path("container-dmg")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine tar-gz-based Casks" do
|
it "does not quarantine tar-gz-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-tar-gz", "--no-quarantine")
|
Cask::Cmd::Install.run("container-tar-gz", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-tar-gz"))
|
||||||
Cask::CaskLoader.load(cask_path("container-tar-gz")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine xar-based Casks" do
|
it "does not quarantine xar-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-xar", "--no-quarantine")
|
Cask::Cmd::Install.run("container-xar", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-xar"))
|
||||||
Cask::CaskLoader.load(cask_path("container-xar")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine pure bzip2-based Casks" do
|
it "does not quarantine pure bzip2-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-bzip2", "--no-quarantine")
|
Cask::Cmd::Install.run("container-bzip2", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-bzip2"))
|
||||||
Cask::CaskLoader.load(cask_path("container-bzip2")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine pure gzip-based Casks" do
|
it "does not quarantine pure gzip-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-gzip", "--no-quarantine")
|
Cask::Cmd::Install.run("container-gzip", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-gzip"))
|
||||||
Cask::CaskLoader.load(cask_path("container-gzip")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine the pkg in naked-pkg-based Casks" do
|
it "does not quarantine the pkg in naked-pkg-based Casks" do
|
||||||
@ -227,11 +223,11 @@ describe Cask::Quarantine, :cask do
|
|||||||
it "does not quarantine a nested container" do
|
it "does not quarantine a nested container" do
|
||||||
Cask::Cmd::Install.run("nested-app", "--no-quarantine")
|
Cask::Cmd::Install.run("nested-app", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("nested-app"))
|
||||||
Cask::CaskLoader.load(cask_path("nested-app")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("MyNestedApp.app")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("MyNestedApp.app")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,7 +14,7 @@ HOMEBREW_CASK_DIRS = {
|
|||||||
RSpec.shared_context "Homebrew Cask", :needs_macos do
|
RSpec.shared_context "Homebrew Cask", :needs_macos do
|
||||||
before do
|
before do
|
||||||
HOMEBREW_CASK_DIRS.each do |method, path|
|
HOMEBREW_CASK_DIRS.each do |method, path|
|
||||||
allow(Cask::Config.global).to receive(method).and_return(path)
|
Cask::Config.global.send("#{method}=", path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user