MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / runCommand

Function runCommand

apps/cli/src/release.ts:73–100  ·  view source on GitHub ↗
(input: CommandInput)

Source from the content-addressed store, hash-verified

71};
72
73const runCommand = async (input: CommandInput): Promise<CommandOutput> => {
74 const proc = Bun.spawn([input.command, ...input.args], {
75 cwd: input.cwd,
76 env: process.env,
77 stdio: input.captureOutput ? ["ignore", "pipe", "pipe"] : ["ignore", "inherit", "inherit"],
78 });
79
80 const exitCode = await proc.exited;
81 const stdout = input.captureOutput && proc.stdout ? await new Response(proc.stdout).text() : "";
82 const stderr = input.captureOutput && proc.stderr ? await new Response(proc.stderr).text() : "";
83
84 if (exitCode !== 0) {
85 throw new Error(
86 [
87 `${input.command} ${input.args.join(" ")} exited with code ${exitCode}`,
88 stdout.trim().length > 0 ? `stdout:\n${stdout.trim()}` : null,
89 stderr.trim().length > 0 ? `stderr:\n${stderr.trim()}` : null,
90 ]
91 .filter((part) => part !== null)
92 .join("\n\n"),
93 );
94 }
95
96 return {
97 stdout: stdout.trim(),
98 stderr: stderr.trim(),
99 };
100};
101
102const readVersion = async (): Promise<string> => {
103 const pkg = (await Bun.file(versionPackagePath).json()) as { version?: string };

Callers 3

packWrapperPackageFunction · 0.70
syncGitHubReleaseFunction · 0.70
mainFunction · 0.70

Calls 1

textMethod · 0.65

Tested by

no test coverage detected