cask/artifact/relocated: don't evaluate URL on creation

This commit is contained in:
Bo Anderson 2022-10-31 13:07:25 +00:00
parent 31758eaa02
commit ad4730395a
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65

View File

@ -39,8 +39,6 @@ module Cask
target target
end end
attr_reader :source, :target
sig { sig {
params(cask: Cask, source: T.nilable(T.any(String, Pathname)), target_hash: T.any(String, Pathname)) params(cask: Cask, source: T.nilable(T.any(String, Pathname)), target_hash: T.any(String, Pathname))
.void .void
@ -51,12 +49,18 @@ module Cask
target = target_hash[:target] target = target_hash[:target]
@source_string = source.to_s @source_string = source.to_s
@target_string = target.to_s @target_string = target.to_s
base_path = cask.staged_path end
base_path = base_path.join(cask.url.only_path) if cask.url&.only_path.present?
source = base_path.join(source) def source
@source = source @source ||= begin
target ||= source.basename base_path = cask.staged_path
@target = resolve_target(target) base_path = base_path.join(cask.url.only_path) if cask.url&.only_path.present?
base_path.join(@source_string)
end
end
def target
@target ||= resolve_target(@target_string.presence || source.basename)
end end
def to_a def to_a