@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
21 lines • 1.1 kB
JavaScript
import { dirname, join } from "node:path";
const BUN_LAUNCHER_REPAIR_SOURCE = `
import { renameSync, writeFileSync } from "node:fs";
const [launcher, entrypoint] = process.argv.slice(1);
if (!launcher || !entrypoint) throw new Error("Missing Bun launcher repair path");
const quote = (value) => "'" + value.replaceAll("'", "'\\"'\\"'") + "'";
const temporary = launcher + "." + process.pid + ".tmp";
writeFileSync(temporary, "#!/bin/sh\\nexec " + quote(process.execPath) + " " + quote(entrypoint) + " \\"$@\\"\\n", { mode: 0o755 });
renameSync(temporary, launcher);
`.trim();
export function createBunLauncherRepairCommand(binDir, packageName, executableName) {
const packageDir = join(dirname(binDir), "install", "global", "node_modules", ...packageName.split("/"));
const launcher = join(binDir, executableName);
const entrypoint = join(packageDir, "dist", "cli.js");
return {
command: "bun",
args: ["-e", BUN_LAUNCHER_REPAIR_SOURCE, launcher, entrypoint],
display: `repair Bun launcher ${launcher}`,
};
}
//# sourceMappingURL=bun-global-launcher.js.map