2024-09-21 12:24:21 -07:00
|
|
|
# typed: strict
|
2022-11-21 21:04:22 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-09-21 12:24:21 -07:00
|
|
|
module OS
|
|
|
|
module Linux
|
|
|
|
module SimulateSystem
|
2025-06-21 21:40:57 -04:00
|
|
|
module ClassMethods
|
|
|
|
sig { returns(T.nilable(Symbol)) }
|
|
|
|
def os
|
|
|
|
@os ||= T.let(nil, T.nilable(Symbol))
|
|
|
|
return :macos if @os.blank? && Homebrew::EnvConfig.simulate_macos_on_linux?
|
2022-11-21 21:04:22 -08:00
|
|
|
|
2025-06-21 21:40:57 -04:00
|
|
|
@os
|
|
|
|
end
|
2022-11-21 21:04:22 -08:00
|
|
|
|
2025-06-21 21:40:57 -04:00
|
|
|
sig { returns(T::Boolean) }
|
|
|
|
def simulating_or_running_on_linux?
|
|
|
|
os.blank? || os == :linux
|
|
|
|
end
|
2022-11-21 21:04:22 -08:00
|
|
|
|
2025-06-21 21:40:57 -04:00
|
|
|
sig { returns(Symbol) }
|
|
|
|
def current_os
|
|
|
|
os || :linux
|
|
|
|
end
|
2022-11-21 21:04:22 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2024-09-21 12:24:21 -07:00
|
|
|
|
2025-06-21 21:40:57 -04:00
|
|
|
Homebrew::SimulateSystem.singleton_class.prepend(OS::Linux::SimulateSystem::ClassMethods)
|