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

Function resolveNativeBinary

scripts/platform.js:36–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34}
35
36function resolveNativeBinary() {
37 const pkgName = getPlatformPackageName();
38 if (pkgName) {
39 try {
40 const pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
41 const binPath = path.join(pkgDir, "bin", BINARY_FILENAME);
42 if (fs.existsSync(binPath)) {
43 return { path: binPath, fromPlatformPkg: true };
44 }
45 } catch (err) {
46 if (err.code !== "MODULE_NOT_FOUND") {
47 console.warn(`[WARN] Unexpected error resolving ${pkgName}: ${err.message}`);
48 }
49 }
50 }
51
52 const legacyPath = path.join(__dirname, "..", "bin", BINARY_FILENAME);
53 if (fs.existsSync(legacyPath)) {
54 return { path: legacyPath, fromPlatformPkg: false };
55 }
56
57 return null;
58}
59
60module.exports = {
61 IS_WINDOWS,

Callers 3

mainFunction · 0.85
mainFunction · 0.85
ocr.jsFile · 0.85

Calls 1

getPlatformPackageNameFunction · 0.85

Tested by

no test coverage detected