Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]
import { spawnSync } from "node:child_process";
import os from "node:os";
import { normalizeOptionalString } from "../shared/string-coerce.js";
export type OsSummary = {
platform: NodeJS.Platform;
arch: string;
release: string;
label: string;
};
const cachedOsSummaryByKey = new Map<string, OsSummary>();
function macosVersion(): string {
const res = spawnSync("sw_vers", ["-productVersion"], { encoding: "utf-8" });
const out = normalizeOptionalString(res.stdout) ?? "";
return out || os.release();
}
export function resolveOsSummary(): OsSummary {
const platform = os.platform();
const release = os.release();
const arch = os.arch();
const cacheKey = `${platform}\0${release}\0${arch}`;
const cached = cachedOsSummaryByKey.get(cacheKey);
if (cached) {
return cached;
}
const label = (() => {
if (platform === "darwin") {
return `macos ${macosVersion()} (${arch})`;
}
if (platform === "win32") {
return `windows ${release} (${arch})`;
}
return `${platform} ${release} (${arch})`;
})();
const summary = { platform, arch, release, label };
cachedOsSummaryByKey.set(cacheKey, summary);
return summary;
}
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet am 2026-04-27)
¤
*© Formatika GbR, Deutschland