MCPcopy Create free account
hub / github.com/vercel/vercel / detectPlatform

Function detectPlatform

packages/python/src/platform-info.ts:40–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38 * doesn't have a Linux libc).
39 */
40export function detectPlatform(): PlatformInfo {
41 const SYS_PLATFORM_MAP: Record<string, string> = {
42 linux: 'linux',
43 win32: 'win32',
44 darwin: 'darwin',
45 };
46 const OS_MAP: Record<string, string> = {
47 linux: 'linux',
48 win32: 'windows',
49 darwin: 'macos',
50 };
51
52 const arch = os.arch();
53 const libcFamily = detectLibc.familySync();
54 const libcVersion = detectLibc.versionSync();
55
56 const platform: PlatformInfo = {
57 osName: 'manylinux',
58 archName: ARCH_MAP[arch] || arch,
59 osMajor: 2,
60 osMinor: 17,
61 os: OS_MAP[process.platform] || 'linux',
62 sysPlatform: SYS_PLATFORM_MAP[process.platform] || 'linux',
63 libc: 'gnu',
64 };
65
66 if (libcFamily === detectLibc.MUSL) {
67 platform.osName = 'musllinux';
68 platform.libc = 'musl';
69 }
70
71 if (libcVersion) {
72 const parts = libcVersion.split('.');
73 platform.osMajor = parseInt(parts[0], 10);
74 platform.osMinor = parseInt(parts[1], 10) || 0;
75 }
76
77 return platform;
78}
79
80/** Validate and normalize a VERCEL_BUILD_ARCH value. */
81export function validateBuildArch(arch: string): 'x86_64' | 'aarch64' {

Callers 2

toPythonBuildFunction · 0.90
detectTargetPlatformFunction · 0.85

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected