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

Function detectPlatform

scripts/install.js:31–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31function detectPlatform() {
32 let os = process.platform;
33 let arch = process.arch;
34
35 switch (arch) {
36 case "x64":
37 arch = "amd64";
38 break;
39 case "arm64":
40 arch = "arm64";
41 break;
42 default:
43 throw new Error(
44 `Unsupported architecture: ${arch}. Supported: amd64 (x64), arm64`
45 );
46 }
47
48 switch (os) {
49 case "linux":
50 case "darwin":
51 break;
52 case "win32":
53 os = "windows";
54 break;
55 default:
56 throw new Error(
57 `Unsupported operating system: ${os}. Supported: linux, darwin, win32`
58 );
59 }
60
61 return { os, arch };
62}
63
64function loadPackageJson() {
65 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