fix(runner): prefer package-matching binary over utility bins
Some checks failed
CI / Typecheck (push) Has been cancelled
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled
CI / Lint (push) Has been cancelled

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-08 15:28:50 +01:00
parent b0634b829c
commit 8a3c96dc7c

View File

@@ -264,9 +264,13 @@ const server = createServer(async (req, res) => {
if (npxPackage) {
const binDir = join(svcSourcePath, "node_modules", ".bin");
if (existsSync(binDir)) {
const bins = readdirSync(binDir);
if (bins.length > 0) {
svc._npxBin = join(binDir, bins[0]);
const bins = readdirSync(binDir).filter(b => !["node-which", "which", "semver", "resolve"].includes(b));
// Prefer binary matching the package name
const pkgShort = npxPackage.split("/").pop().replace(/^@/, "");
const match = bins.find(b => b === pkgShort || b.includes(pkgShort)) || bins[0];
if (match) {
svc._npxBin = join(binDir, match);
console.log(`[runner] npx binary resolved: ${match}`);
}
}
}