MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / resolveWorkerdBinary

Function resolveWorkerdBinary

apps/cli/src/build.ts:319–352  ·  view source on GitHub ↗
(t: Target)

Source from the content-addressed store, hash-verified

317};
318
319const resolveWorkerdBinary = (t: Target): string | null => {
320 const platformMap: Record<string, string> = {
321 "darwin-arm64": "@cloudflare/workerd-darwin-arm64",
322 "darwin-x64": "@cloudflare/workerd-darwin-64",
323 "linux-arm64": "@cloudflare/workerd-linux-arm64",
324 "linux-x64": "@cloudflare/workerd-linux-64",
325 "win32-x64": "@cloudflare/workerd-windows-64",
326 };
327 const key = [t.os, t.arch, t.abi].filter(Boolean).join("-");
328 const pkg = platformMap[key];
329 if (!pkg) return null;
330 const binary = workerdBinaryName(t);
331 try {
332 const req = createRequire(
333 join(repoRoot, "packages/kernel/runtime-workerd-subprocess/package.json"),
334 );
335 const pkgJson = req.resolve(`${pkg}/package.json`);
336 for (const candidate of [
337 join(dirname(pkgJson), "bin", binary),
338 join(dirname(pkgJson), binary),
339 ]) {
340 if (existsSync(candidate)) return candidate;
341 }
342 } catch {
343 const packageRoot = join(
344 repoRoot,
345 `node_modules/.bun/${pkg.replace("/", "+")}@${WORKERD_VERSION}/node_modules/${pkg}`,
346 );
347 for (const candidate of [join(packageRoot, "bin", binary), join(packageRoot, binary)]) {
348 if (existsSync(candidate)) return candidate;
349 }
350 }
351 return null;
352};
353
354// ---------------------------------------------------------------------------
355// Build mode

Callers 1

buildBinariesFunction · 0.85

Calls 3

resolveMethod · 0.80
workerdBinaryNameFunction · 0.70
replaceMethod · 0.65

Tested by

no test coverage detected