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

Function runCommand

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

Source from the content-addressed store, hash-verified

46};
47
48const runCommand = async (input: CommandInput): Promise<CommandOutput> => {
49 const proc = Bun.spawn([input.command, ...input.args], {
50 cwd: input.cwd,
51 env: process.env,
52 stdio: input.captureOutput ? ["ignore", "pipe", "pipe"] : ["ignore", "inherit", "inherit"],
53 });
54
55 const exitCode = await proc.exited;
56 const stdout = input.captureOutput && proc.stdout ? await new Response(proc.stdout).text() : "";
57 const stderr = input.captureOutput && proc.stderr ? await new Response(proc.stderr).text() : "";
58
59 if (exitCode !== 0) {
60 throw new Error(
61 [
62 `${input.command} ${input.args.join(" ")} exited with code ${exitCode}`,
63 stdout.trim().length > 0 ? `stdout:\n${stdout.trim()}` : null,
64 stderr.trim().length > 0 ? `stderr:\n${stderr.trim()}` : null,
65 ]
66 .filter((part) => part !== null)
67 .join("\n\n"),
68 );
69 }
70
71 return {
72 stdout: stdout.trim(),
73 stderr: stderr.trim(),
74 };
75};
76
77const readVersion = async (): Promise<string> => {
78 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