utils/tar: Bump to Sorbet typed: strict
This commit is contained in:
parent
3290b7e616
commit
5b84ee0195
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "system_command"
|
require "system_command"
|
||||||
@ -11,18 +11,21 @@ module Utils
|
|||||||
|
|
||||||
TAR_FILE_EXTENSIONS = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ].freeze
|
TAR_FILE_EXTENSIONS = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ].freeze
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
def available?
|
def available?
|
||||||
executable.present?
|
executable.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T.nilable(Pathname)) }
|
||||||
def executable
|
def executable
|
||||||
return @executable if defined?(@executable)
|
return @executable if defined?(@executable)
|
||||||
|
|
||||||
gnu_tar_gtar_path = HOMEBREW_PREFIX/"opt/gnu-tar/bin/gtar"
|
gnu_tar_gtar_path = HOMEBREW_PREFIX/"opt/gnu-tar/bin/gtar"
|
||||||
gnu_tar_gtar = gnu_tar_gtar_path if gnu_tar_gtar_path.executable?
|
gnu_tar_gtar = gnu_tar_gtar_path if gnu_tar_gtar_path.executable?
|
||||||
@executable = which("gtar") || gnu_tar_gtar || which("tar")
|
@executable = T.let((which("gtar") || gnu_tar_gtar || which("tar")), T.nilable(Pathname))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(path: T.any(Pathname, String)).void }
|
||||||
def validate_file(path)
|
def validate_file(path)
|
||||||
return unless available?
|
return unless available?
|
||||||
|
|
||||||
@ -33,6 +36,7 @@ module Utils
|
|||||||
odie "#{path} is not a valid tar file!" if !status.success? || stdout.blank?
|
odie "#{path} is not a valid tar file!" if !status.success? || stdout.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def clear_executable_cache
|
def clear_executable_cache
|
||||||
remove_instance_variable(:@executable) if defined?(@executable)
|
remove_instance_variable(:@executable) if defined?(@executable)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user