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

Function resolveNativeBinary

scripts/platform.js:39–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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