MCPcopy
hub / github.com/shareAI-lab/Kode-CLI / tryResolveNativeBinaryFromOptionalDeps

Function tryResolveNativeBinaryFromOptionalDeps

cli-acp.js:7–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5const { spawnSync } = require('node:child_process')
6
7function tryResolveNativeBinaryFromOptionalDeps() {
8 const platform = process.platform
9 const arch = process.arch
10
11 const candidates = [`@shareai-lab/kode-bin-${platform}-${arch}`]
12
13 if (platform === 'win32' && arch === 'arm64') {
14 candidates.push('@shareai-lab/kode-bin-win32-x64')
15 }
16
17 for (const pkgName of candidates) {
18 try {
19 // eslint-disable-next-line import/no-dynamic-require
20 const mod = require(pkgName)
21 const binPath = mod?.kodePath
22 if (typeof binPath === 'string' && fs.existsSync(binPath)) {
23 return binPath
24 }
25 } catch {}
26 }
27
28 return null
29}
30
31function findPackageRoot(startDir) {
32 let dir = startDir

Callers 1

mainFunction · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected