ENV/super: add shims_path helper method.

This allows us to stop repeatedly hardcoding this on macOS/Linux in
formulae.
This commit is contained in:
Mike McQuaid 2021-09-08 12:35:36 +01:00
parent 5c602003f2
commit 2b6e580636
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
3 changed files with 21 additions and 2 deletions

View File

@ -29,6 +29,13 @@ module Superenv
base.run_time_deps = []
end
# The location of Homebrew's shims on this OS.
# @public
sig { returns(Pathname) }
def self.shims_path
HOMEBREW_SHIMS_PATH/"super"
end
# @private
sig { returns(T.nilable(Pathname)) }
def self.bin; end

View File

@ -4,9 +4,15 @@
module Superenv
extend T::Sig
# The location of Homebrew's shims on Linux.
# @public
def self.shims_path
HOMEBREW_SHIMS_PATH/"linux/super"
end
# @private
def self.bin
(HOMEBREW_SHIMS_PATH/"linux/super").realpath
shims_path.realpath
end
# @private

View File

@ -5,13 +5,19 @@ module Superenv
extend T::Sig
class << self
# The location of Homebrew's shims on macOS.
# @public
def shims_path
HOMEBREW_SHIMS_PATH/"mac/super"
end
undef bin
# @private
def bin
return unless DevelopmentTools.installed?
(HOMEBREW_SHIMS_PATH/"mac/super").realpath
shims_path.realpath
end
end