Refactor global Cask::Config.
This commit is contained in:
parent
cac8e7aac5
commit
5f005f67cf
@ -80,11 +80,14 @@ module Cask
|
|||||||
|
|
||||||
def audit_languages(languages)
|
def audit_languages(languages)
|
||||||
ohai "Auditing language: #{languages.map { |lang| "'#{lang}'" }.to_sentence}"
|
ohai "Auditing language: #{languages.map { |lang| "'#{lang}'" }.to_sentence}"
|
||||||
localized_cask = CaskLoader.load(cask.sourcefile_path)
|
|
||||||
config = localized_cask.config
|
original_config = cask.config
|
||||||
config.languages = languages
|
localized_config = original_config.merge(Config.new(explicit: { languages: languages }))
|
||||||
localized_cask.config = config
|
cask.config = localized_config
|
||||||
audit_cask_instance(localized_cask)
|
|
||||||
|
audit_cask_instance(cask)
|
||||||
|
ensure
|
||||||
|
cask.config = original_config
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_cask_instance(cask)
|
def audit_cask_instance(cask)
|
||||||
|
|||||||
@ -16,13 +16,13 @@ module Cask
|
|||||||
extend Searchable
|
extend Searchable
|
||||||
include Metadata
|
include Metadata
|
||||||
|
|
||||||
attr_reader :token, :sourcefile_path, :config
|
attr_reader :token, :sourcefile_path, :config, :default_config
|
||||||
|
|
||||||
def self.each(&block)
|
def self.each(&block)
|
||||||
return to_enum unless block_given?
|
return to_enum unless block_given?
|
||||||
|
|
||||||
Tap.flat_map(&:cask_files).each do |f|
|
Tap.flat_map(&:cask_files).each do |f|
|
||||||
block.call CaskLoader::FromTapPathLoader.new(f).load
|
block.call CaskLoader::FromTapPathLoader.new(f).load(config: nil)
|
||||||
rescue CaskUnreadableError => e
|
rescue CaskUnreadableError => e
|
||||||
opoo e.message
|
opoo e.message
|
||||||
end
|
end
|
||||||
@ -34,12 +34,19 @@ module Cask
|
|||||||
@tap
|
@tap
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(token, sourcefile_path: nil, tap: nil, &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
|
||||||
@block = block
|
@block = block
|
||||||
self.config = Config.for_cask(self)
|
|
||||||
|
@default_config = config || Config.new
|
||||||
|
|
||||||
|
self.config = if config_path.exist?
|
||||||
|
Config.from_json(File.read(config_path))
|
||||||
|
else
|
||||||
|
@default_config
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def config=(config)
|
def config=(config)
|
||||||
|
|||||||
@ -19,8 +19,8 @@ module Cask
|
|||||||
content = ref.to_str
|
content = ref.to_str
|
||||||
|
|
||||||
token = /(?:"[^"]*"|'[^']*')/
|
token = /(?:"[^"]*"|'[^']*')/
|
||||||
curly = /\(\s*#{token}\s*\)\s*\{.*\}/
|
curly = /\(\s*#{token.source}\s*\)\s*\{.*\}/
|
||||||
do_end = /\s+#{token}\s+do(?:\s*;\s*|\s+).*end/
|
do_end = /\s+#{token.source}\s+do(?:\s*;\s*|\s+).*end/
|
||||||
regex = /\A\s*cask(?:#{curly.source}|#{do_end.source})\s*\Z/m
|
regex = /\A\s*cask(?:#{curly.source}|#{do_end.source})\s*\Z/m
|
||||||
|
|
||||||
content.match?(regex)
|
content.match?(regex)
|
||||||
@ -30,14 +30,16 @@ module Cask
|
|||||||
@content = content.force_encoding("UTF-8")
|
@content = content.force_encoding("UTF-8")
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load(config:)
|
||||||
|
@config = config
|
||||||
|
|
||||||
instance_eval(content, __FILE__, __LINE__)
|
instance_eval(content, __FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def cask(header_token, **options, &block)
|
def cask(header_token, **options, &block)
|
||||||
Cask.new(header_token, **options, &block)
|
Cask.new(header_token, **options, config: @config, &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -57,19 +59,22 @@ module Cask
|
|||||||
@path = path
|
@path = path
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load(config:)
|
||||||
raise CaskUnavailableError.new(token, "'#{path}' does not exist.") unless path.exist?
|
raise CaskUnavailableError.new(token, "'#{path}' does not exist.") unless path.exist?
|
||||||
raise CaskUnavailableError.new(token, "'#{path}' is not readable.") unless path.readable?
|
raise CaskUnavailableError.new(token, "'#{path}' is not readable.") unless path.readable?
|
||||||
raise CaskUnavailableError.new(token, "'#{path}' is not a file.") unless path.file?
|
raise CaskUnavailableError.new(token, "'#{path}' is not a file.") unless path.file?
|
||||||
|
|
||||||
@content = IO.read(path)
|
@content = path.read(encoding: "UTF-8")
|
||||||
|
@config = config
|
||||||
|
|
||||||
begin
|
begin
|
||||||
instance_eval(content, path).tap do |cask|
|
instance_eval(content, path).tap do |cask|
|
||||||
raise CaskUnreadableError.new(token, "'#{path}' does not contain a cask.") unless cask.is_a?(Cask)
|
raise CaskUnreadableError.new(token, "'#{path}' does not contain a cask.") unless cask.is_a?(Cask)
|
||||||
end
|
end
|
||||||
rescue NameError, ArgumentError, ScriptError => e
|
rescue NameError, ArgumentError, ScriptError => e
|
||||||
raise CaskUnreadableError.new(token, e.message)
|
error = CaskUnreadableError.new(token, e.message)
|
||||||
|
error.set_backtrace e.backtrace
|
||||||
|
raise error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -102,7 +107,7 @@ module Cask
|
|||||||
super Cache.path/File.basename(@url.path)
|
super Cache.path/File.basename(@url.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load(config:)
|
||||||
path.dirname.mkpath
|
path.dirname.mkpath
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -147,7 +152,7 @@ module Cask
|
|||||||
super Tap.fetch(user, repo).cask_dir/"#{token}.rb"
|
super Tap.fetch(user, repo).cask_dir/"#{token}.rb"
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load(config:)
|
||||||
tap.install unless tap.installed?
|
tap.install unless tap.installed?
|
||||||
|
|
||||||
super
|
super
|
||||||
@ -156,8 +161,6 @@ module Cask
|
|||||||
|
|
||||||
# Loads a cask from an existing {Cask} instance.
|
# Loads a cask from an existing {Cask} instance.
|
||||||
class FromInstanceLoader
|
class FromInstanceLoader
|
||||||
attr_reader :cask
|
|
||||||
|
|
||||||
def self.can_load?(ref)
|
def self.can_load?(ref)
|
||||||
ref.is_a?(Cask)
|
ref.is_a?(Cask)
|
||||||
end
|
end
|
||||||
@ -166,8 +169,8 @@ module Cask
|
|||||||
@cask = cask
|
@cask = cask
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load(config:)
|
||||||
cask
|
@cask
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -182,7 +185,7 @@ module Cask
|
|||||||
super CaskLoader.default_path(token)
|
super CaskLoader.default_path(token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load(config:)
|
||||||
raise CaskUnavailableError.new(token, "No Cask with this name exists.")
|
raise CaskUnavailableError.new(token, "No Cask with this name exists.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -191,8 +194,8 @@ module Cask
|
|||||||
self.for(ref).path
|
self.for(ref).path
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load(ref)
|
def self.load(ref, config: nil)
|
||||||
self.for(ref).load
|
self.for(ref).load(config: config)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.for(ref)
|
def self.for(ref)
|
||||||
|
|||||||
@ -36,9 +36,9 @@ module Cask
|
|||||||
token = path.basename.to_s
|
token = path.basename.to_s
|
||||||
|
|
||||||
if tap_path = CaskLoader.tap_paths(token).first
|
if tap_path = CaskLoader.tap_paths(token).first
|
||||||
CaskLoader::FromTapPathLoader.new(tap_path).load
|
CaskLoader::FromTapPathLoader.new(tap_path).load(config: nil)
|
||||||
elsif caskroom_path = Pathname.glob(path.join(".metadata/*/*/*/*.rb")).first
|
elsif caskroom_path = Pathname.glob(path.join(".metadata/*/*/*/*.rb")).first
|
||||||
CaskLoader::FromPathLoader.new(caskroom_path).load
|
CaskLoader::FromPathLoader.new(caskroom_path).load(config: nil)
|
||||||
else
|
else
|
||||||
CaskLoader.load(token)
|
CaskLoader.load(token)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -236,12 +236,6 @@ module Cask
|
|||||||
|
|
||||||
args = self.class.parser.parse(argv, ignore_invalid_options: true)
|
args = self.class.parser.parse(argv, ignore_invalid_options: true)
|
||||||
|
|
||||||
Config::DEFAULT_DIRS.each_key do |name|
|
|
||||||
Config.global.public_send(:"#{name}=", args[name]) if args[name]
|
|
||||||
end
|
|
||||||
|
|
||||||
Config.global.languages = args.language if args.language
|
|
||||||
|
|
||||||
Tap.default_cask_tap.install unless Tap.default_cask_tap.installed?
|
Tap.default_cask_tap.install unless Tap.default_cask_tap.installed?
|
||||||
|
|
||||||
command, argv = detect_internal_command(*argv) ||
|
command, argv = detect_internal_command(*argv) ||
|
||||||
|
|||||||
@ -106,8 +106,7 @@ module Cask
|
|||||||
def casks(alternative: -> { [] })
|
def casks(alternative: -> { [] })
|
||||||
return @casks if defined?(@casks)
|
return @casks if defined?(@casks)
|
||||||
|
|
||||||
casks = args.named.empty? ? alternative.call : args.named
|
@casks = args.named.empty? ? alternative.call : args.named.to_casks
|
||||||
@casks = casks.map { |cask| CaskLoader.load(cask) }
|
|
||||||
rescue CaskUnavailableError => e
|
rescue CaskUnavailableError => e
|
||||||
reason = [e.reason, *suggestion_message(e.token)].join(" ")
|
reason = [e.reason, *suggestion_message(e.token)].join(" ")
|
||||||
raise e.class.new(e.token, reason)
|
raise e.class.new(e.token, reason)
|
||||||
|
|||||||
@ -62,8 +62,8 @@ module Cask
|
|||||||
else
|
else
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
end.map(&CaskLoader.public_method(:load))
|
end
|
||||||
|
casks = casks.map { |c| CaskLoader.load(c, config: Config.from_args(args)) }
|
||||||
casks = Cask.to_a if casks.empty?
|
casks = Cask.to_a if casks.empty?
|
||||||
|
|
||||||
failed_casks = casks.reject do |cask|
|
failed_casks = casks.reject do |cask|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ module Cask
|
|||||||
old_cask_installer =
|
old_cask_installer =
|
||||||
Installer.new(old_cask, **old_options)
|
Installer.new(old_cask, **old_options)
|
||||||
|
|
||||||
new_cask.config = Config.global.merge(old_config)
|
new_cask.config = new_cask.default_config.merge(old_config)
|
||||||
|
|
||||||
new_options = {
|
new_options = {
|
||||||
binaries: binaries,
|
binaries: binaries,
|
||||||
|
|||||||
@ -36,20 +36,24 @@ module Cask
|
|||||||
}.merge(DEFAULT_DIRS).freeze
|
}.merge(DEFAULT_DIRS).freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.global
|
def self.from_args(args)
|
||||||
@global ||= new
|
new(explicit: {
|
||||||
end
|
appdir: args.appdir,
|
||||||
|
colorpickerdir: args.colorpickerdir,
|
||||||
def self.clear
|
prefpanedir: args.prefpanedir,
|
||||||
@global = nil
|
qlplugindir: args.qlplugindir,
|
||||||
end
|
mdimporterdir: args.mdimporterdir,
|
||||||
|
dictionarydir: args.dictionarydir,
|
||||||
def self.for_cask(cask)
|
fontdir: args.fontdir,
|
||||||
if cask.config_path.exist?
|
servicedir: args.servicedir,
|
||||||
from_json(File.read(cask.config_path))
|
input_methoddir: args.input_methoddir,
|
||||||
else
|
internet_plugindir: args.internet_plugindir,
|
||||||
global
|
audio_unit_plugindir: args.audio_unit_plugindir,
|
||||||
end
|
vst_plugindir: args.vst_plugindir,
|
||||||
|
vst3_plugindir: args.vst3_plugindir,
|
||||||
|
screen_saverdir: args.screen_saverdir,
|
||||||
|
languages: args.language,
|
||||||
|
}.compact)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_json(json)
|
def self.from_json(json)
|
||||||
@ -95,19 +99,19 @@ module Cask
|
|||||||
|
|
||||||
def env
|
def env
|
||||||
@env ||= self.class.canonicalize(
|
@env ||= self.class.canonicalize(
|
||||||
Shellwords.shellsplit(ENV.fetch("HOMEBREW_CASK_OPTS", ""))
|
Homebrew::EnvConfig.cask_opts
|
||||||
.select { |arg| arg.include?("=") }
|
.select { |arg| arg.include?("=") }
|
||||||
.map { |arg| arg.split("=", 2) }
|
.map { |arg| arg.split("=", 2) }
|
||||||
.map do |(flag, value)|
|
.map do |(flag, value)|
|
||||||
key = flag.sub(/^--/, "")
|
key = flag.sub(/^--/, "")
|
||||||
|
|
||||||
if key == "language"
|
if key == "language"
|
||||||
key = "languages"
|
key = "languages"
|
||||||
value = value.split(",")
|
value = value.split(",")
|
||||||
end
|
end
|
||||||
|
|
||||||
[key, value]
|
[key, value]
|
||||||
end,
|
end,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -99,7 +99,7 @@ module 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?
|
||||||
stage
|
stage
|
||||||
|
|
||||||
@cask.config = Config.global.merge(old_config)
|
@cask.config = @cask.default_config.merge(old_config)
|
||||||
|
|
||||||
install_artifacts
|
install_artifacts
|
||||||
|
|
||||||
@ -284,10 +284,11 @@ module Cask
|
|||||||
|
|
||||||
if cask_or_formula.is_a?(Cask)
|
if cask_or_formula.is_a?(Cask)
|
||||||
formula_deps = cask_or_formula.depends_on.formula.map { |f| Formula[f] }
|
formula_deps = cask_or_formula.depends_on.formula.map { |f| Formula[f] }
|
||||||
cask_deps = cask_or_formula.depends_on.cask.map(&CaskLoader.public_method(:load))
|
cask_deps = cask_or_formula.depends_on.cask.map { |c| CaskLoader.load(c, config: nil) }
|
||||||
else
|
else
|
||||||
formula_deps = cask_or_formula.deps.reject(&:build?).map(&:to_formula)
|
formula_deps = cask_or_formula.deps.reject(&:build?).map(&:to_formula)
|
||||||
cask_deps = cask_or_formula.requirements.map(&:cask).compact.map(&CaskLoader.public_method(:load))
|
cask_deps = cask_or_formula.requirements.map(&:cask).compact
|
||||||
|
.map { |c| CaskLoader.load(c, config: nil) }
|
||||||
end
|
end
|
||||||
|
|
||||||
acc[cask_or_formula] ||= []
|
acc[cask_or_formula] ||= []
|
||||||
|
|||||||
@ -20,7 +20,7 @@ module Homebrew
|
|||||||
|
|
||||||
# Can set these because they will be overwritten by freeze_named_args!
|
# Can set these because they will be overwritten by freeze_named_args!
|
||||||
# (whereas other values below will only be overwritten if passed).
|
# (whereas other values below will only be overwritten if passed).
|
||||||
self[:named_args] = NamedArgs.new
|
self[:named_args] = NamedArgs.new(parent: self)
|
||||||
self[:remaining] = []
|
self[:remaining] = []
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ module Homebrew
|
|||||||
override_spec: spec(nil),
|
override_spec: spec(nil),
|
||||||
force_bottle: force_bottle?,
|
force_bottle: force_bottle?,
|
||||||
flags: flags_only,
|
flags: flags_only,
|
||||||
|
parent: self,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def named
|
def named
|
||||||
named_args || NamedArgs.new
|
named_args
|
||||||
end
|
end
|
||||||
|
|
||||||
def no_named?
|
def no_named?
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cask/cask_loader"
|
|
||||||
require "delegate"
|
require "delegate"
|
||||||
|
|
||||||
|
require "cask/cask_loader"
|
||||||
|
require "cli/args"
|
||||||
require "formulary"
|
require "formulary"
|
||||||
require "missing_formula"
|
require "missing_formula"
|
||||||
|
|
||||||
@ -11,11 +13,12 @@ module Homebrew
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
class NamedArgs < SimpleDelegator
|
class NamedArgs < SimpleDelegator
|
||||||
def initialize(*args, override_spec: nil, force_bottle: false, flags: [])
|
def initialize(*args, parent: Args.new, override_spec: nil, force_bottle: false, flags: [])
|
||||||
@args = args
|
@args = args
|
||||||
@override_spec = override_spec
|
@override_spec = override_spec
|
||||||
@force_bottle = force_bottle
|
@force_bottle = force_bottle
|
||||||
@flags = flags
|
@flags = flags
|
||||||
|
@parent = parent
|
||||||
|
|
||||||
super(@args)
|
super(@args)
|
||||||
end
|
end
|
||||||
@ -130,7 +133,9 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_casks
|
def to_casks
|
||||||
@to_casks ||= downcased_unique_named.map(&Cask::CaskLoader.method(:load)).freeze
|
@to_casks ||= downcased_unique_named
|
||||||
|
.map { |name| Cask::CaskLoader.load(name, config: Cask::Config.from_args(@parent)) }
|
||||||
|
.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_kegs
|
def to_kegs
|
||||||
@ -155,7 +160,7 @@ module Homebrew
|
|||||||
warn_if_cask_conflicts(name, "keg")
|
warn_if_cask_conflicts(name, "keg")
|
||||||
rescue NoSuchKegError, FormulaUnavailableError
|
rescue NoSuchKegError, FormulaUnavailableError
|
||||||
begin
|
begin
|
||||||
casks << Cask::CaskLoader.load(name)
|
casks << Cask::CaskLoader.load(name, config: Cask::Config.from_args(@parent))
|
||||||
rescue Cask::CaskUnavailableError
|
rescue Cask::CaskUnavailableError
|
||||||
raise "No installed keg or cask with the name \"#{name}\""
|
raise "No installed keg or cask with the name \"#{name}\""
|
||||||
end
|
end
|
||||||
|
|||||||
@ -174,7 +174,7 @@ module Homebrew
|
|||||||
|
|
||||||
def outdated_casks(args:)
|
def outdated_casks(args:)
|
||||||
if args.named.present?
|
if args.named.present?
|
||||||
select_outdated(args.named.uniq.map(&Cask::CaskLoader.method(:load)), args: args)
|
select_outdated(args.named.to_casks, args: args)
|
||||||
else
|
else
|
||||||
select_outdated(Cask::Caskroom.casks, args: args)
|
select_outdated(Cask::Caskroom.casks, args: args)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7,10 +7,16 @@ 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.binarydir.join("binary") }
|
let(:binarydir) { cask.config.binarydir }
|
||||||
|
let(:expected_path) { binarydir.join("binary") }
|
||||||
|
|
||||||
after do
|
around do |example|
|
||||||
FileUtils.rm expected_path if expected_path.exist?
|
binarydir.mkpath
|
||||||
|
|
||||||
|
example.run
|
||||||
|
ensure
|
||||||
|
FileUtils.rm_f expected_path
|
||||||
|
FileUtils.rmdir binarydir
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when --no-binaries is specified" do
|
context "when --no-binaries is specified" do
|
||||||
@ -80,7 +86,7 @@ describe Cask::Artifact::Binary, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "creates parent directory if it doesn't exist" do
|
it "creates parent directory if it doesn't exist" do
|
||||||
FileUtils.rmdir Cask::Config.global.binarydir
|
FileUtils.rmdir binarydir
|
||||||
|
|
||||||
artifacts.each do |artifact|
|
artifacts.each do |artifact|
|
||||||
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
|
||||||
|
|||||||
@ -13,7 +13,7 @@ describe Cask::CaskLoader::FromPathLoader do
|
|||||||
|
|
||||||
it "raises an error" do
|
it "raises an error" do
|
||||||
expect {
|
expect {
|
||||||
described_class.new(path).load
|
described_class.new(path).load(config: nil)
|
||||||
}.to raise_error(Cask::CaskUnreadableError, /does not contain a cask/)
|
}.to raise_error(Cask::CaskUnreadableError, /does not contain a cask/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -29,7 +29,7 @@ describe Cask::CaskLoader::FromPathLoader do
|
|||||||
|
|
||||||
it "raises an error" do
|
it "raises an error" do
|
||||||
expect {
|
expect {
|
||||||
described_class.new(path).load
|
described_class.new(path).load(config: nil)
|
||||||
}.to raise_error(Cask::CaskUnreadableError, /undefined local variable or method/)
|
}.to raise_error(Cask::CaskUnreadableError, /undefined local variable or method/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -20,7 +20,7 @@ describe Cask::Cmd::Audit, :cask do
|
|||||||
|
|
||||||
it "audits specified Casks if tokens are given" do
|
it "audits specified Casks if tokens are given" do
|
||||||
cask_token = "nice-app"
|
cask_token = "nice-app"
|
||||||
expect(Cask::CaskLoader).to receive(:load).with(cask_token).and_return(cask)
|
expect(Cask::CaskLoader).to receive(:load).with(cask_token, any_args).and_return(cask)
|
||||||
|
|
||||||
expect(Cask::Auditor).to receive(:audit)
|
expect(Cask::Auditor).to receive(:audit)
|
||||||
.with(cask, quarantine: true)
|
.with(cask, quarantine: true)
|
||||||
|
|||||||
@ -23,6 +23,19 @@ describe Cask::Cmd::Cat, :cask do
|
|||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
}
|
}
|
||||||
|
let(:caffeine_content) {
|
||||||
|
<<~'RUBY'
|
||||||
|
cask "local-caffeine" do
|
||||||
|
version "1.2.3"
|
||||||
|
sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94"
|
||||||
|
|
||||||
|
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
|
||||||
|
homepage "https://brew.sh/"
|
||||||
|
|
||||||
|
app "Caffeine.app"
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
}
|
||||||
|
|
||||||
it "displays the Cask file content about the specified Cask" do
|
it "displays the Cask file content about the specified Cask" do
|
||||||
expect {
|
expect {
|
||||||
@ -32,8 +45,8 @@ describe Cask::Cmd::Cat, :cask do
|
|||||||
|
|
||||||
it "can display multiple Casks" do
|
it "can display multiple Casks" do
|
||||||
expect {
|
expect {
|
||||||
described_class.run("basic-cask", "basic-cask")
|
described_class.run("basic-cask", "local-caffeine")
|
||||||
}.to output(basic_cask_content * 2).to_stdout
|
}.to output(basic_cask_content + caffeine_content).to_stdout
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,50 @@ describe Cask::Cmd::Install, :cask do
|
|||||||
expect(caffeine.config.appdir.join("Caffeine.app")).to be_a_directory
|
expect(caffeine.config.appdir.join("Caffeine.app")).to be_a_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "recognizes the --appdir flag" do
|
||||||
|
appdir = mktmpdir
|
||||||
|
|
||||||
|
expect(Cask::CaskLoader).to receive(:load).with("local-caffeine", any_args)
|
||||||
|
.and_wrap_original { |f, *args|
|
||||||
|
caffeine = f.call(*args)
|
||||||
|
expect(caffeine.config.appdir).to eq appdir
|
||||||
|
caffeine
|
||||||
|
}
|
||||||
|
|
||||||
|
described_class.run("local-caffeine", "--appdir=#{appdir}")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "recognizes the --appdir flag from HOMEBREW_CASK_OPTS" do
|
||||||
|
appdir = mktmpdir
|
||||||
|
|
||||||
|
expect(Cask::CaskLoader).to receive(:load).with("local-caffeine", any_args)
|
||||||
|
.and_wrap_original { |f, *args|
|
||||||
|
caffeine = f.call(*args)
|
||||||
|
expect(caffeine.config.appdir).to eq appdir
|
||||||
|
caffeine
|
||||||
|
}
|
||||||
|
|
||||||
|
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=#{appdir}"
|
||||||
|
|
||||||
|
described_class.run("local-caffeine")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "prefers an explicit --appdir flag to one from HOMEBREW_CASK_OPTS" do
|
||||||
|
global_appdir = mktmpdir
|
||||||
|
appdir = mktmpdir
|
||||||
|
|
||||||
|
expect(Cask::CaskLoader).to receive(:load).with("local-caffeine", any_args)
|
||||||
|
.and_wrap_original { |f, *args|
|
||||||
|
caffeine = f.call(*args)
|
||||||
|
expect(caffeine.config.appdir).to eq appdir
|
||||||
|
caffeine
|
||||||
|
}
|
||||||
|
|
||||||
|
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=#{global_appdir}"
|
||||||
|
|
||||||
|
described_class.run("local-caffeine", "--appdir=#{appdir}")
|
||||||
|
end
|
||||||
|
|
||||||
it "skips double install (without nuking existing installation)" do
|
it "skips double install (without nuking existing installation)" do
|
||||||
described_class.run("local-transmission")
|
described_class.run("local-transmission")
|
||||||
described_class.run("local-transmission")
|
described_class.run("local-transmission")
|
||||||
|
|||||||
@ -30,7 +30,8 @@ describe Cask::Cmd::Style, :cask do
|
|||||||
subject { cli.cask_paths }
|
subject { cli.cask_paths }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(cli).to receive(:args).and_return(instance_double(Homebrew::CLI::Args, named: tokens))
|
args = instance_double(Homebrew::CLI::Args, named: Homebrew::CLI::NamedArgs.new(*tokens))
|
||||||
|
allow(cli).to receive(:args).and_return(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when no cask tokens are given" do
|
context "when no cask tokens are given" do
|
||||||
|
|||||||
@ -64,7 +64,7 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
Cask::Installer.new(cask).install
|
Cask::Installer.new(cask).install
|
||||||
|
|
||||||
expect(cask).to be_installed
|
expect(cask).to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("MyFancyApp.app")).to exist
|
expect(cask.config.appdir.join("MyFancyApp.app")).to exist
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
described_class.run("with-uninstall-script-app")
|
described_class.run("with-uninstall-script-app")
|
||||||
@ -143,8 +143,8 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when Casks in Taps have been renamed or removed" do
|
context "when Casks in Taps have been renamed or removed" do
|
||||||
let(:app) { Cask::Config.global.appdir.join("ive-been-renamed.app") }
|
let(:app) { Cask::Config.new.appdir.join("ive-been-renamed.app") }
|
||||||
let(:caskroom_path) { Cask::Caskroom.path.join("ive-been-renamed").tap(&:mkpath) }
|
let(:caskroom_path) { Cask::Caskroom.path.join("ive-been-renamed").tap(&:mkpath) }
|
||||||
let(:saved_caskfile) {
|
let(:saved_caskfile) {
|
||||||
caskroom_path.join(".metadata", "latest", "timestamp", "Casks").join("ive-been-renamed.rb")
|
caskroom_path.join(".metadata", "latest", "timestamp", "Casks").join("ive-been-renamed.rb")
|
||||||
@ -168,7 +168,7 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can still uninstall those Casks" do
|
it "can still uninstall them" do
|
||||||
described_class.run("ive-been-renamed")
|
described_class.run("ive-been-renamed")
|
||||||
|
|
||||||
expect(app).not_to exist
|
expect(app).not_to exist
|
||||||
|
|||||||
@ -3,6 +3,16 @@
|
|||||||
require_relative "shared_examples/invalid_option"
|
require_relative "shared_examples/invalid_option"
|
||||||
|
|
||||||
describe Cask::Cmd::Upgrade, :cask do
|
describe Cask::Cmd::Upgrade, :cask do
|
||||||
|
let(:version_latest_path_2) { version_latest.config.appdir.join("Caffeine Pro.app") }
|
||||||
|
let(:version_latest_path_1) { version_latest.config.appdir.join("Caffeine Mini.app") }
|
||||||
|
let(:version_latest) { Cask::CaskLoader.load("version-latest") }
|
||||||
|
let(:auto_updates_path) { auto_updates.config.appdir.join("MyFancyApp.app") }
|
||||||
|
let(:auto_updates) { Cask::CaskLoader.load("auto-updates") }
|
||||||
|
let(:local_transmission_path) { local_transmission.config.appdir.join("Transmission.app") }
|
||||||
|
let(:local_transmission) { Cask::CaskLoader.load("local-transmission") }
|
||||||
|
let(:local_caffeine_path) { local_caffeine.config.appdir.join("Caffeine.app") }
|
||||||
|
let(:local_caffeine) { Cask::CaskLoader.load("local-caffeine") }
|
||||||
|
|
||||||
it_behaves_like "a command that handles invalid options"
|
it_behaves_like "a command that handles invalid options"
|
||||||
|
|
||||||
context "successful upgrade" do
|
context "successful upgrade" do
|
||||||
@ -23,11 +33,6 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
describe 'without --greedy it ignores the Casks with "version latest" or "auto_updates true"' do
|
describe 'without --greedy it ignores the Casks with "version latest" or "auto_updates true"' do
|
||||||
it "updates all the installed Casks when no token is provided" do
|
it "updates all the installed Casks when no token is provided" do
|
||||||
local_caffeine = Cask::CaskLoader.load("local-caffeine")
|
|
||||||
local_caffeine_path = Cask::Config.global.appdir.join("Caffeine.app")
|
|
||||||
local_transmission = Cask::CaskLoader.load("local-transmission")
|
|
||||||
local_transmission_path = Cask::Config.global.appdir.join("Transmission.app")
|
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
expect(local_caffeine.versions).to include("1.2.2")
|
expect(local_caffeine.versions).to include("1.2.2")
|
||||||
@ -48,11 +53,6 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "updates only the Casks specified in the command line" do
|
it "updates only the Casks specified in the command line" do
|
||||||
local_caffeine = Cask::CaskLoader.load("local-caffeine")
|
|
||||||
local_caffeine_path = Cask::Config.global.appdir.join("Caffeine.app")
|
|
||||||
local_transmission = Cask::CaskLoader.load("local-transmission")
|
|
||||||
local_transmission_path = Cask::Config.global.appdir.join("Transmission.app")
|
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
expect(local_caffeine.versions).to include("1.2.2")
|
expect(local_caffeine.versions).to include("1.2.2")
|
||||||
@ -73,11 +73,6 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'updates "auto_updates" and "latest" Casks when their tokens are provided in the command line' do
|
it 'updates "auto_updates" and "latest" Casks when their tokens are provided in the command line' do
|
||||||
local_caffeine = Cask::CaskLoader.load("local-caffeine")
|
|
||||||
local_caffeine_path = Cask::Config.global.appdir.join("Caffeine.app")
|
|
||||||
auto_updates = Cask::CaskLoader.load("auto-updates")
|
|
||||||
auto_updates_path = Cask::Config.global.appdir.join("MyFancyApp.app")
|
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
expect(local_caffeine.versions).to include("1.2.2")
|
expect(local_caffeine.versions).to include("1.2.2")
|
||||||
@ -100,16 +95,6 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
describe "with --greedy it checks additional Casks" do
|
describe "with --greedy it checks additional Casks" do
|
||||||
it 'includes the Casks with "auto_updates true" or "version latest"' do
|
it 'includes the Casks with "auto_updates true" or "version latest"' do
|
||||||
local_caffeine = Cask::CaskLoader.load("local-caffeine")
|
|
||||||
local_caffeine_path = Cask::Config.global.appdir.join("Caffeine.app")
|
|
||||||
auto_updates = Cask::CaskLoader.load("auto-updates")
|
|
||||||
auto_updates_path = Cask::Config.global.appdir.join("MyFancyApp.app")
|
|
||||||
local_transmission = Cask::CaskLoader.load("local-transmission")
|
|
||||||
local_transmission_path = Cask::Config.global.appdir.join("Transmission.app")
|
|
||||||
version_latest = Cask::CaskLoader.load("version-latest")
|
|
||||||
version_latest_path_1 = Cask::Config.global.appdir.join("Caffeine Mini.app")
|
|
||||||
version_latest_path_2 = Cask::Config.global.appdir.join("Caffeine Pro.app")
|
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
expect(local_caffeine.versions).to include("1.2.2")
|
expect(local_caffeine.versions).to include("1.2.2")
|
||||||
@ -148,24 +133,21 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
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")
|
expect(auto_updates).to be_installed
|
||||||
cask_path = cask.config.appdir.join("MyFancyApp.app")
|
expect(auto_updates_path).to be_a_directory
|
||||||
|
expect(auto_updates.versions).to include("2.57")
|
||||||
expect(cask).to be_installed
|
|
||||||
expect(cask_path).to be_a_directory
|
|
||||||
expect(cask.versions).to include("2.57")
|
|
||||||
|
|
||||||
described_class.run("auto-updates", "--greedy")
|
described_class.run("auto-updates", "--greedy")
|
||||||
|
|
||||||
expect(cask).to be_installed
|
expect(auto_updates).to be_installed
|
||||||
expect(cask_path).to be_a_directory
|
expect(auto_updates_path).to be_a_directory
|
||||||
expect(cask.versions).to include("2.61")
|
expect(auto_updates.versions).to include("2.61")
|
||||||
|
|
||||||
described_class.run("auto-updates", "--greedy")
|
described_class.run("auto-updates", "--greedy")
|
||||||
|
|
||||||
expect(cask).to be_installed
|
expect(auto_updates).to be_installed
|
||||||
expect(cask_path).to be_a_directory
|
expect(auto_updates_path).to be_a_directory
|
||||||
expect(cask.versions).to include("2.61")
|
expect(auto_updates.versions).to include("2.61")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -188,11 +170,6 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
describe 'without --greedy it ignores the Casks with "version latest" or "auto_updates true"' do
|
describe 'without --greedy it ignores the Casks with "version latest" or "auto_updates true"' do
|
||||||
it "would update all the installed Casks when no token is provided" do
|
it "would update all the installed Casks when no token is provided" do
|
||||||
local_caffeine = Cask::CaskLoader.load("local-caffeine")
|
|
||||||
local_caffeine_path = Cask::Config.global.appdir.join("Caffeine.app")
|
|
||||||
local_transmission = Cask::CaskLoader.load("local-transmission")
|
|
||||||
local_transmission_path = Cask::Config.global.appdir.join("Transmission.app")
|
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
expect(local_caffeine.versions).to include("1.2.2")
|
expect(local_caffeine.versions).to include("1.2.2")
|
||||||
@ -215,11 +192,6 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "would update only the Casks specified in the command line" do
|
it "would update only the Casks specified in the command line" do
|
||||||
local_caffeine = Cask::CaskLoader.load("local-caffeine")
|
|
||||||
local_caffeine_path = Cask::Config.global.appdir.join("Caffeine.app")
|
|
||||||
local_transmission = Cask::CaskLoader.load("local-transmission")
|
|
||||||
local_transmission_path = Cask::Config.global.appdir.join("Transmission.app")
|
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
expect(local_caffeine.versions).to include("1.2.2")
|
expect(local_caffeine.versions).to include("1.2.2")
|
||||||
@ -242,11 +214,6 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'would update "auto_updates" and "latest" Casks when their tokens are provided in the command line' do
|
it 'would update "auto_updates" and "latest" Casks when their tokens are provided in the command line' do
|
||||||
local_caffeine = Cask::CaskLoader.load("local-caffeine")
|
|
||||||
local_caffeine_path = Cask::Config.global.appdir.join("Caffeine.app")
|
|
||||||
auto_updates = Cask::CaskLoader.load("auto-updates")
|
|
||||||
auto_updates_path = Cask::Config.global.appdir.join("MyFancyApp.app")
|
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
expect(local_caffeine.versions).to include("1.2.2")
|
expect(local_caffeine.versions).to include("1.2.2")
|
||||||
@ -271,16 +238,6 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
describe "with --greedy it checks additional Casks" do
|
describe "with --greedy it checks additional Casks" do
|
||||||
it 'would include the Casks with "auto_updates true" or "version latest"' do
|
it 'would include the Casks with "auto_updates true" or "version latest"' do
|
||||||
local_caffeine = Cask::CaskLoader.load("local-caffeine")
|
|
||||||
local_caffeine_path = Cask::Config.global.appdir.join("Caffeine.app")
|
|
||||||
auto_updates = Cask::CaskLoader.load("auto-updates")
|
|
||||||
auto_updates_path = Cask::Config.global.appdir.join("MyFancyApp.app")
|
|
||||||
local_transmission = Cask::CaskLoader.load("local-transmission")
|
|
||||||
local_transmission_path = Cask::Config.global.appdir.join("Transmission.app")
|
|
||||||
version_latest = Cask::CaskLoader.load("version-latest")
|
|
||||||
version_latest_path_1 = Cask::Config.global.appdir.join("Caffeine Mini.app")
|
|
||||||
version_latest_path_2 = Cask::Config.global.appdir.join("Caffeine Pro.app")
|
|
||||||
|
|
||||||
expect(local_caffeine).to be_installed
|
expect(local_caffeine).to be_installed
|
||||||
expect(local_caffeine_path).to be_a_directory
|
expect(local_caffeine_path).to be_a_directory
|
||||||
expect(local_caffeine.versions).to include("1.2.2")
|
expect(local_caffeine.versions).to include("1.2.2")
|
||||||
@ -319,26 +276,23 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
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")
|
expect(auto_updates).to be_installed
|
||||||
cask_path = cask.config.appdir.join("MyFancyApp.app")
|
expect(auto_updates_path).to be_a_directory
|
||||||
|
expect(auto_updates.versions).to include("2.57")
|
||||||
expect(cask).to be_installed
|
|
||||||
expect(cask_path).to be_a_directory
|
|
||||||
expect(cask.versions).to include("2.57")
|
|
||||||
|
|
||||||
described_class.run("--dry-run", "auto-updates", "--greedy")
|
described_class.run("--dry-run", "auto-updates", "--greedy")
|
||||||
|
|
||||||
expect(cask).to be_installed
|
expect(auto_updates).to be_installed
|
||||||
expect(cask_path).to be_a_directory
|
expect(auto_updates_path).to be_a_directory
|
||||||
expect(cask.versions).to include("2.57")
|
expect(auto_updates.versions).to include("2.57")
|
||||||
expect(cask.versions).not_to include("2.61")
|
expect(auto_updates.versions).not_to include("2.61")
|
||||||
|
|
||||||
described_class.run("--dry-run", "auto-updates", "--greedy")
|
described_class.run("--dry-run", "auto-updates", "--greedy")
|
||||||
|
|
||||||
expect(cask).to be_installed
|
expect(auto_updates).to be_installed
|
||||||
expect(cask_path).to be_a_directory
|
expect(auto_updates_path).to be_a_directory
|
||||||
expect(cask.versions).to include("2.57")
|
expect(auto_updates.versions).to include("2.57")
|
||||||
expect(cask.versions).not_to include("2.61")
|
expect(auto_updates.versions).not_to include("2.61")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -417,9 +371,6 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
bad_checksum = Cask::CaskLoader.load("bad-checksum")
|
bad_checksum = Cask::CaskLoader.load("bad-checksum")
|
||||||
bad_checksum_path = bad_checksum.config.appdir.join("Caffeine.app")
|
bad_checksum_path = bad_checksum.config.appdir.join("Caffeine.app")
|
||||||
|
|
||||||
local_transmission = Cask::CaskLoader.load("local-transmission")
|
|
||||||
local_transmission_path = Cask::Config.global.appdir.join("Transmission.app")
|
|
||||||
|
|
||||||
bad_checksum_2 = Cask::CaskLoader.load("bad-checksum2")
|
bad_checksum_2 = Cask::CaskLoader.load("bad-checksum2")
|
||||||
bad_checksum_2_path = bad_checksum_2.config.appdir.join("container")
|
bad_checksum_2_path = bad_checksum_2.config.appdir.join("container")
|
||||||
|
|
||||||
|
|||||||
@ -16,26 +16,6 @@ describe Cask::Cmd, :cask do
|
|||||||
}.to output(/Displays information about the given cask/).to_stdout
|
}.to output(/Displays information about the given cask/).to_stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
it "respects the env variable when choosing what appdir to create" do
|
|
||||||
allow(described_class).to receive(:lookup_command).with("noop").and_return(noop_command)
|
|
||||||
|
|
||||||
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/custom/appdir"
|
|
||||||
|
|
||||||
described_class.run("noop")
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir).to eq(Pathname.new("/custom/appdir"))
|
|
||||||
end
|
|
||||||
|
|
||||||
it "overrides the env variable when passing --appdir directly" do
|
|
||||||
allow(described_class).to receive(:lookup_command).with("noop").and_return(noop_command)
|
|
||||||
|
|
||||||
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/custom/appdir"
|
|
||||||
|
|
||||||
described_class.run("noop", "--appdir=/even/more/custom/appdir")
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir).to eq(Pathname.new("/even/more/custom/appdir"))
|
|
||||||
end
|
|
||||||
|
|
||||||
it "exits with a status of 1 when something goes wrong" do
|
it "exits with a status of 1 when something goes wrong" do
|
||||||
allow(described_class).to receive(:lookup_command).and_raise(Cask::CaskError)
|
allow(described_class).to receive(:lookup_command).and_raise(Cask::CaskError)
|
||||||
command = described_class.new("noop")
|
command = described_class.new("noop")
|
||||||
|
|||||||
@ -503,16 +503,15 @@ describe Cask::DSL, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "does not include a trailing slash" do
|
it "does not include a trailing slash" do
|
||||||
original_appdir = Cask::Config.global.appdir
|
config = Cask::Config.new(explicit: {
|
||||||
Cask::Config.global.appdir = "#{original_appdir}/"
|
appdir: "/Applications/",
|
||||||
|
})
|
||||||
|
|
||||||
cask = Cask::Cask.new("appdir-trailing-slash") do
|
cask = Cask::Cask.new("appdir-trailing-slash", config: config) do
|
||||||
binary "#{appdir}/some/path"
|
binary "#{appdir}/some/path"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(cask.artifacts.first.source).to eq(original_appdir/"some/path")
|
expect(cask.artifacts.first.source).to eq(Pathname("/Applications/some/path"))
|
||||||
ensure
|
|
||||||
Cask::Config.global.appdir = original_appdir
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -195,7 +195,7 @@ describe Cask::Installer, :cask do
|
|||||||
|
|
||||||
described_class.new(nested_app).install
|
described_class.new(nested_app).install
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("MyNestedApp.app")).to be_a_directory
|
expect(nested_app.config.appdir.join("MyNestedApp.app")).to be_a_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
it "generates and finds a timestamped metadata directory for an installed Cask" do
|
it "generates and finds a timestamped metadata directory for an installed Cask" do
|
||||||
|
|||||||
@ -37,7 +37,6 @@ RSpec.shared_context "Homebrew Cask", :needs_macos do
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Cask::Config::DEFAULT_DIRS_PATHNAMES.values.each(&:mkpath)
|
Cask::Config::DEFAULT_DIRS_PATHNAMES.values.each(&:mkpath)
|
||||||
Cask::Config.global.binarydir.mkpath
|
|
||||||
|
|
||||||
Tap.default_cask_tap.tap do |tap|
|
Tap.default_cask_tap.tap do |tap|
|
||||||
FileUtils.mkdir_p tap.path.dirname
|
FileUtils.mkdir_p tap.path.dirname
|
||||||
@ -52,11 +51,10 @@ RSpec.shared_context "Homebrew Cask", :needs_macos do
|
|||||||
example.run
|
example.run
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm_rf Cask::Config::DEFAULT_DIRS_PATHNAMES.values
|
FileUtils.rm_rf Cask::Config::DEFAULT_DIRS_PATHNAMES.values
|
||||||
FileUtils.rm_rf [Cask::Config.global.binarydir, Cask::Caskroom.path, Cask::Cache.path]
|
FileUtils.rm_rf [Cask::Config.new.binarydir, Cask::Caskroom.path, Cask::Cache.path]
|
||||||
Tap.default_cask_tap.path.unlink
|
Tap.default_cask_tap.path.unlink
|
||||||
third_party_tap.path.unlink
|
third_party_tap.path.unlink
|
||||||
FileUtils.rm_rf third_party_tap.path.parent
|
FileUtils.rm_rf third_party_tap.path.parent
|
||||||
Cask::Config.clear
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user