mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Move SimulateSystem check to extend/os
This commit is contained in:
parent
1db5d967c3
commit
2eee1e7c2a
29
Library/Homebrew/extend/os/linux/simulate_system.rb
Normal file
29
Library/Homebrew/extend/os/linux/simulate_system.rb
Normal file
@ -0,0 +1,29 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
class SimulateSystem
|
||||
class << self
|
||||
undef os
|
||||
undef simulating_or_running_on_linux?
|
||||
undef current_os
|
||||
|
||||
sig { returns(T.nilable(Symbol)) }
|
||||
def os
|
||||
return :macos if @os.blank? && Homebrew::EnvConfig.simulate_macos_on_linux?
|
||||
|
||||
@os
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def simulating_or_running_on_linux?
|
||||
os.blank? || os == :linux
|
||||
end
|
||||
|
||||
sig { returns(Symbol) }
|
||||
def current_os
|
||||
os || :linux
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
Library/Homebrew/extend/os/mac/simulate_system.rb
Normal file
21
Library/Homebrew/extend/os/mac/simulate_system.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Homebrew
|
||||
class SimulateSystem
|
||||
class << self
|
||||
undef simulating_or_running_on_macos?
|
||||
undef current_os
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def simulating_or_running_on_macos?
|
||||
os.blank? || [:macos, *MacOSVersions::SYMBOLS.keys].include?(os)
|
||||
end
|
||||
|
||||
sig { returns(Symbol) }
|
||||
def current_os
|
||||
os || MacOS.version.to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
8
Library/Homebrew/extend/os/simulate_system.rb
Normal file
8
Library/Homebrew/extend/os/simulate_system.rb
Normal file
@ -0,0 +1,8 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
if OS.mac?
|
||||
require "extend/os/mac/simulate_system"
|
||||
elsif OS.linux?
|
||||
require "extend/os/linux/simulate_system"
|
||||
end
|
@ -9,14 +9,7 @@ module Homebrew
|
||||
class << self
|
||||
extend T::Sig
|
||||
|
||||
attr_reader :arch
|
||||
|
||||
sig { returns(T.nilable(Symbol)) }
|
||||
def os
|
||||
return :macos if @os.blank? && !OS.mac? && Homebrew::EnvConfig.simulate_macos_on_linux?
|
||||
|
||||
@os
|
||||
end
|
||||
attr_reader :arch, :os
|
||||
|
||||
sig { params(new_os: Symbol).void }
|
||||
def os=(new_os)
|
||||
@ -40,15 +33,11 @@ module Homebrew
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def simulating_or_running_on_macos?
|
||||
return OS.mac? if os.blank?
|
||||
|
||||
[:macos, *MacOSVersions::SYMBOLS.keys].include?(os)
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def simulating_or_running_on_linux?
|
||||
return OS.linux? if os.blank?
|
||||
|
||||
os == :linux
|
||||
end
|
||||
|
||||
@ -59,11 +48,10 @@ module Homebrew
|
||||
|
||||
sig { returns(Symbol) }
|
||||
def current_os
|
||||
return T.must(os) if os.present?
|
||||
return :linux if OS.linux?
|
||||
|
||||
MacOS.version.to_sym
|
||||
os || :generic
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "extend/os/simulate_system"
|
||||
|
Loading…
x
Reference in New Issue
Block a user