MCPcopy Index your code
hub / github.com/MiniMax-AI/cli / detectPlatform

Function detectPlatform

src/update/self-update.ts:28–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26export type Channel = 'stable' | 'latest' | string; // string = exact version tag
27
28async function detectPlatform(): Promise<string> {
29 const os = process.platform;
30 const arch = process.arch;
31
32 const osMap: Record<string, string> = { darwin: 'darwin', linux: 'linux' };
33 const archMap: Record<string, string> = { x64: 'x64', arm64: 'arm64' };
34
35 const mappedOs = osMap[os];
36 const mappedArch = archMap[arch];
37
38 if (!mappedOs || !mappedArch) {
39 throw new CLIError(`Unsupported platform: ${os}/${arch}`, ExitCode.GENERAL);
40 }
41
42 // Detect musl on Linux
43 if (mappedOs === 'linux') {
44 try {
45 const { execSync } = await import('child_process');
46 const ldd = execSync('ldd /bin/ls 2>&1', { encoding: 'utf-8' });
47 if (ldd.includes('musl')) return `linux-${mappedArch}-musl`;
48 } catch { /* non-fatal */ }
49 }
50
51 return `${mappedOs}-${mappedArch}`;
52}
53
54async function ghFetch(path: string): Promise<Response> {
55 const headers: Record<string, string> = {

Callers 1

resolveUpdateTargetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected