Skip to content

Commit d5079c0

Browse files
committed
Fix noisy CLI error output
1 parent 6e8f6b0 commit d5079c0

4 files changed

Lines changed: 31 additions & 12 deletions

File tree

.alfonso/release-notes/v0.1.2.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# @cortexkit/orw v0.1.2
2+
3+
Small CLI output cleanup release.
4+
5+
## Fixes
6+
7+
- Fixed `install-ready` printing the full internal `ps` process list while checking whether OpenCode is running.
8+
- CLI failures now print only the error message instead of a Bun stack trace.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ Full user-facing release notes live in GitHub Releases. This file is a lightweig
66

77
## 0.1.x
88

9+
- **0.1.2** — Stopped internal command captures from printing to the terminal and made CLI failures print concise messages instead of Bun stack traces.
910
- **0.1.1** — Added CLI help output and made unknown commands show help instead of a Bun stack trace.
1011
- **0.1.0** — Initial public release of `@cortexkit/orw`: Bun-powered OpenCode release integration watcher with macOS/Linux/Windows CLI support plus local branch, GitHub branch URL, and GitHub PR URL integration sources.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cortexkit/orw",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Local OpenCode release integration watcher",
55
"keywords": [
66
"opencode",

src/index.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ type OpenCodeProcess = {
6565
command: string;
6666
};
6767

68+
type ExecInput = {
69+
cwd?: string;
70+
log?: string;
71+
env?: Record<string, string>;
72+
printStdout?: boolean;
73+
printStderr?: boolean;
74+
};
75+
6876
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
6977
const packageName = "@cortexkit/orw";
7078
const configFileName = "orw.config.json";
@@ -1034,25 +1042,21 @@ async function note(file: string, text: string) {
10341042
await fs.writeFile(file, text, { flag: "a" });
10351043
}
10361044

1037-
async function run(cmd: string[], input?: { cwd?: string; log?: string; env?: Record<string, string> }) {
1045+
async function run(cmd: string[], input?: ExecInput) {
10381046
const code = await exec(cmd, input);
10391047
if (code !== 0) throw new Error(`${cmd[0]} exited with ${code}`);
10401048
return code;
10411049
}
10421050

1043-
async function textOut(cmd: string[], input?: { cwd?: string; log?: string; env?: Record<string, string> }) {
1051+
async function textOut(cmd: string[], input?: ExecInput) {
10441052
let data = "";
1045-
await exec(cmd, input, (chunk) => {
1053+
await exec(cmd, { ...input, printStdout: false }, (chunk) => {
10461054
data += chunk;
10471055
});
10481056
return data.trim();
10491057
}
10501058

1051-
async function exec(
1052-
cmd: string[],
1053-
input?: { cwd?: string; log?: string; env?: Record<string, string> },
1054-
onStdout?: (chunk: string) => void,
1055-
) {
1059+
async function exec(cmd: string[], input?: ExecInput, onStdout?: (chunk: string) => void) {
10561060
return await new Promise<number>((resolve, reject) => {
10571061
const child = spawn(cmd[0], cmd.slice(1), {
10581062
cwd: input?.cwd,
@@ -1065,13 +1069,13 @@ async function exec(
10651069
};
10661070
child.stdout.on("data", (buf: Buffer) => {
10671071
const chunk = String(buf);
1068-
process.stdout.write(chunk);
1072+
if (input?.printStdout !== false) process.stdout.write(chunk);
10691073
onStdout?.(chunk);
10701074
void write(chunk);
10711075
});
10721076
child.stderr.on("data", (buf: Buffer) => {
10731077
const chunk = String(buf);
1074-
process.stderr.write(chunk);
1078+
if (input?.printStderr !== false) process.stderr.write(chunk);
10751079
void write(chunk);
10761080
});
10771081
child.on("error", reject);
@@ -1087,4 +1091,10 @@ function out(text: string) {
10871091
process.stdout.write(`${text}\n`);
10881092
}
10891093

1090-
await main();
1094+
try {
1095+
await main();
1096+
} catch (err) {
1097+
const message = err instanceof Error ? err.message : String(err);
1098+
process.stderr.write(`${message}\n`);
1099+
process.exitCode = 1;
1100+
}

0 commit comments

Comments
 (0)