mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
25 lines
495 B
TypeScript
25 lines
495 B
TypeScript
import child_process from "child_process";
|
|
import { debug } from "./console";
|
|
|
|
export function spawn(
|
|
cmd: string,
|
|
args: string[],
|
|
options: child_process.SpawnOptions = {},
|
|
): {
|
|
exitCode: number;
|
|
stdout: string;
|
|
stderr: string;
|
|
} {
|
|
debug("spawn", [cmd, ...args].join(" "));
|
|
const { status, stdout, stderr } = child_process.spawnSync(cmd, args, {
|
|
stdio: "pipe",
|
|
encoding: "utf-8",
|
|
...options,
|
|
});
|
|
return {
|
|
exitCode: status ?? 1,
|
|
stdout,
|
|
stderr,
|
|
};
|
|
}
|