Merge pull request #14065 from Bo98/cask-url-evaluate

cask/artifact/relocated: don't evaluate URL on creation
This commit is contained in:
Mike McQuaid 2022-10-31 13:39:03 +00:00 committed by GitHub
commit 876b0dc759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
end
def source
@source ||= begin
base_path = cask.staged_path base_path = cask.staged_path
base_path = base_path.join(cask.url.only_path) if cask.url&.only_path.present? base_path = base_path.join(cask.url.only_path) if cask.url&.only_path.present?
source = base_path.join(source) base_path.join(@source_string)
@source = source end
target ||= source.basename end
@target = resolve_target(target)
def target
@target ||= resolve_target(@target_string.presence || source.basename)
end end
def to_a def to_a