mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
fix(internal): improve macOS version detection
Turns out that `sw_vers -productVersion` doesn't always return a version string with a `MAJOR.MINOR.PATCH` format, but can also just return two digits, like `11.0` on the current beta of macOS Big Sur. Fixes: #13
This commit is contained in:
@@ -45,7 +45,7 @@ end
|
||||
class OSVersion
|
||||
def initialize
|
||||
@version = `sw_vers -productVersion`.match(
|
||||
/(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/
|
||||
/(?<major>\d+)(?:\.(?<minor>\d+)(:?\.(?<patch>\d+))?)?/
|
||||
)
|
||||
end
|
||||
|
||||
@@ -54,15 +54,15 @@ class OSVersion
|
||||
end
|
||||
|
||||
def major
|
||||
@major ||= @version[:major].to_i
|
||||
@major ||= @version[:major]&.to_i
|
||||
end
|
||||
|
||||
def minor
|
||||
@minor ||= @version[:minor].to_i
|
||||
@minor ||= @version[:minor]&.to_i
|
||||
end
|
||||
|
||||
def patch
|
||||
@patch ||= @version[:patch].to_i
|
||||
@patch ||= @version[:patch]&.to_i
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user