MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / getRuntimeHostPath

Function getRuntimeHostPath

desktop/runtime-host/client-environment.ts:12–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10let cachedNodeExecutable: string | null = null
11
12export function getRuntimeHostPath() {
13 const siblingWorkerPath = fileURLToPath(new URL('./worker.mjs', import.meta.url))
14 const siblingUnpackedWorkerPath = getAsarUnpackedPath(siblingWorkerPath)
15 if (siblingUnpackedWorkerPath && existsSync(siblingUnpackedWorkerPath)) {
16 return siblingUnpackedWorkerPath
17 }
18 if (existsSync(siblingWorkerPath)) return siblingWorkerPath
19
20 const bundledBridgeWorkerPath = fileURLToPath(new URL('./desktop/worker.mjs', import.meta.url))
21 const bundledBridgeUnpackedWorkerPath = getAsarUnpackedPath(bundledBridgeWorkerPath)
22 if (bundledBridgeUnpackedWorkerPath && existsSync(bundledBridgeUnpackedWorkerPath)) {
23 return bundledBridgeUnpackedWorkerPath
24 }
25 if (existsSync(bundledBridgeWorkerPath)) return bundledBridgeWorkerPath
26
27 return path.join(process.cwd(), 'build', 'desktop', 'worker.mjs')
28}
29
30function getAsarUnpackedPath(filePath: string) {
31 return filePath.includes('.asar') ? filePath.replace('.asar', '.asar.unpacked') : null

Callers 1

ensureRuntimeHostFunction · 0.90

Calls 1

getAsarUnpackedPathFunction · 0.70

Tested by

no test coverage detected