MCPcopy Create free account
hub / github.com/modem-dev/hunk / commandPath

Function commandPath

scripts/smoke-prebuilt-install.ts:43–59  ·  view source on GitHub ↗

Resolve a command path for a sanitized PATH that still works cross-platform.

(command: string)

Source from the content-addressed store, hash-verified

41
42/** Resolve a command path for a sanitized PATH that still works cross-platform. */
43function commandPath(command: string) {
44 const proc = Bun.spawnSync(
45 process.platform === "win32" ? ["where", command] : ["bash", "-lc", `command -v ${command}`],
46 {
47 stdin: "ignore",
48 stdout: "pipe",
49 stderr: "pipe",
50 env: process.env,
51 },
52 );
53 const resolved = Buffer.from(proc.stdout).toString("utf8").split(/\r?\n/, 1)[0]?.trim();
54 if (proc.exitCode !== 0 || !resolved) {
55 throw new Error(`Could not resolve ${command} on PATH for the prebuilt install smoke test.`);
56 }
57
58 return resolved;
59}
60
61/** Resolve a command directory for a sanitized PATH that still works cross-platform. */
62function commandDirectory(command: string) {

Callers 2

commandDirectoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected