(id?: string, idLike?: string)
| 132 | * Exported for direct unit testing without touching the filesystem. |
| 133 | */ |
| 134 | export function distroFamilyFromOsRelease(id?: string, idLike?: string): LinuxDistroFamily { |
| 135 | const haystack = `${id ?? ""} ${idLike ?? ""}`.toLowerCase(); |
| 136 | if (/\b(debian|ubuntu|linuxmint|pop|elementary|raspbian|kali)\b/.test(haystack)) return "debian"; |
| 137 | if (/\b(fedora|rhel|centos|rocky|almalinux|amzn|ol)\b/.test(haystack)) return "fedora"; |
| 138 | if (/\b(arch|manjaro|endeavouros|garuda)\b/.test(haystack)) return "arch"; |
| 139 | if (/\b(alpine)\b/.test(haystack)) return "alpine"; |
| 140 | return "unknown"; |
| 141 | } |
| 142 | |
| 143 | /** Parse the shell-style key=value contents of /etc/os-release. */ |
| 144 | export function parseOsRelease(contents: string): Record<string, string> { |
no outgoing calls
no test coverage detected