MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / parseOsRelease

Function parseOsRelease

packages/cli/src/browser/linuxDeps.ts:144–160  ·  view source on GitHub ↗
(contents: string)

Source from the content-addressed store, hash-verified

142
143/** Parse the shell-style key=value contents of /etc/os-release. */
144export function parseOsRelease(contents: string): Record<string, string> {
145 const out: Record<string, string> = {};
146 for (const rawLine of contents.split("\n")) {
147 const line = rawLine.trim();
148 if (!line || line.startsWith("#")) continue;
149 const eq = line.indexOf("=");
150 if (eq < 0) continue;
151 const key = line.slice(0, eq).trim();
152 let value = line.slice(eq + 1).trim();
153 // Strip surrounding single/double quotes.
154 if (value.length >= 2 && (value[0] === '"' || value[0] === "'") && value.at(-1) === value[0]) {
155 value = value.slice(1, -1);
156 }
157 if (key) out[key] = value;
158 }
159 return out;
160}
161
162/**
163 * Detect the running Linux distribution family and WSL status. Reads

Callers 2

linuxDeps.test.tsFile · 0.85
detectLinuxDistroFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected