Detects the host operating system and, on Linux, parses /etc/os-release.
On macOS, queries sw_vers. Returns a structured platform object used by
the rest of the package. When os_release is supplied and exists, the file
is parsed even on macOS or Windows; this makes fixture-driven testing
practical.
See also
Other platform:
detect_package_manager(),
resolve_platform()
Examples
platform <- detect_platform()
platform$distro
#> [1] "ubuntu"
# Reproducible reads from a fixture file:
fixture <- system.file(
"extdata", "os-release-fedora-40",
package = "sysreqr",
mustWork = FALSE
)
if (nzchar(fixture)) detect_platform(os_release = fixture)
