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

Function run

scripts/smoke-prebuilt-install.ts:21–40  ·  view source on GitHub ↗
(command: string[], options?: { cwd?: string; env?: NodeJS.ProcessEnv })

Source from the content-addressed store, hash-verified

19import { envWithPath, npmCommand } from "./script-helpers";
20
21function run(command: string[], options?: { cwd?: string; env?: NodeJS.ProcessEnv }) {
22 const proc = Bun.spawnSync(command, {
23 cwd: options?.cwd,
24 stdin: "ignore",
25 stdout: "pipe",
26 stderr: "pipe",
27 env: options?.env ?? process.env,
28 });
29
30 const stdout = Buffer.from(proc.stdout).toString("utf8");
31 const stderr = Buffer.from(proc.stderr).toString("utf8");
32
33 if (proc.exitCode !== 0) {
34 throw new Error(
35 `${command.join(" ")} failed with exit ${proc.exitCode}\n${stderr || stdout}`.trim(),
36 );
37 }
38
39 return { stdout, stderr };
40}
41
42/** Resolve a command path for a sanitized PATH that still works cross-platform. */
43function commandPath(command: string) {

Callers 3

withTempStatePathFunction · 0.50
queueHighlightedWorkFunction · 0.50

Calls

no outgoing calls

Tested by 1

withTempStatePathFunction · 0.40