Spaces:
Running
Running
Download tui/src/lib/platform.ts from Leon4gr45/brain: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/tui/src/lib/platform.ts
- Command line
-
hf download hf://spaces/Leon4gr45/brain/tui/src/lib/platform.ts
-
curl -L -o platform.ts https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/tui/src/lib/platform.ts
1.25 kB
| import { currentPlatform } from "./paths.js"; | |
| import { which } from "./exec.js"; | |
| import type { Platform } from "../types.js"; | |
| export type LinuxPackageManager = "apt-get" | "dnf" | "pacman" | "apk" | "zypper"; | |
| export interface PlatformCapabilities { | |
| platform: Platform; | |
| hasBrew: boolean; | |
| hasPyenv: boolean; | |
| hasWinget: boolean; | |
| hasChoco: boolean; | |
| linuxPackageManagers: LinuxPackageManager[]; | |
| } | |
| const LINUX_PMS: LinuxPackageManager[] = [ | |
| "apt-get", | |
| "dnf", | |
| "pacman", | |
| "apk", | |
| "zypper", | |
| ]; | |
| export async function detectCapabilities(): Promise<PlatformCapabilities> { | |
| const platform = currentPlatform(); | |
| const [hasBrew, hasPyenv, hasWinget, hasChoco] = await Promise.all([ | |
| platform === "darwin" || platform === "linux" ? which("brew") : Promise.resolve(false), | |
| which("pyenv"), | |
| platform === "win32" ? which("winget") : Promise.resolve(false), | |
| platform === "win32" ? which("choco") : Promise.resolve(false), | |
| ]); | |
| const linuxPackageManagers: LinuxPackageManager[] = []; | |
| if (platform === "linux") { | |
| for (const pm of LINUX_PMS) { | |
| if (await which(pm)) linuxPackageManagers.push(pm); | |
| } | |
| } | |
| return { | |
| platform, | |
| hasBrew, | |
| hasPyenv, | |
| hasWinget, | |
| hasChoco, | |
| linuxPackageManagers, | |
| }; | |
| } | |