MCPcopy Create free account
hub / github.com/alibaba/open-code-review / detectPlatform

Function detectPlatform

scripts/install.js:27–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27function detectPlatform() {
28 let os = process.platform;
29 let arch = process.arch;
30
31 switch (arch) {
32 case "x64":
33 arch = "amd64";
34 break;
35 case "arm64":
36 arch = "arm64";
37 break;
38 default:
39 throw new Error(
40 `Unsupported architecture: ${arch}. Supported: amd64 (x64), arm64`
41 );
42 }
43
44 switch (os) {
45 case "linux":
46 case "darwin":
47 break;
48 case "win32":
49 os = "windows";
50 break;
51 default:
52 throw new Error(
53 `Unsupported operating system: ${os}. Supported: linux, darwin, win32`
54 );
55 }
56
57 return { os, arch };
58}
59
60function loadPackageJson() {
61 const pkg = JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8"));

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected