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

Function tryResolveNativeBinaryFromOptionalDeps

cli.js:7–30  ·  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 // Windows ARM64 can usually run x64 binaries via emulation, so offer a fallback.
14 if (platform === 'win32' && arch === 'arm64') {
15 candidates.push('@shareai-lab/kode-bin-win32-x64')
16 }
17
18 for (const pkgName of candidates) {
19 try {
20 // eslint-disable-next-line import/no-dynamic-require
21 const mod = require(pkgName)
22 const binPath = mod?.kodePath
23 if (typeof binPath === 'string' && fs.existsSync(binPath)) {
24 return binPath
25 }
26 } catch {}
27 }
28
29 return null
30}
31
32function findPackageRoot(startDir) {
33 let dir = startDir

Callers 1

mainFunction · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected