Skip to content

Commit da24b07

Browse files
koki-developclaude
andcommitted
fix: Do not inherit sandbox exit code in JSON output mode
JSON consumers parse the output to retrieve the sandbox exitCode, so the CLI itself should always exit 0 in --json mode. This makes it easy to distinguish CLI errors from sandbox failures. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8636496 commit da24b07

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/commands/run.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,17 @@ export function registerRunCommand(program: Command): void {
159159
}
160160
}
161161

162-
if (result.data.compile != null && result.data.compile.exitCode !== 0) {
163-
process.exitCode = result.data.compile.exitCode ?? 1;
164-
} else if (result.data.run != null) {
165-
process.exitCode = result.data.run.exitCode ?? 1;
166-
} else {
167-
process.exitCode = 1;
162+
if (!options.json) {
163+
if (
164+
result.data.compile != null &&
165+
result.data.compile.exitCode !== 0
166+
) {
167+
process.exitCode = result.data.compile.exitCode ?? 1;
168+
} else if (result.data.run != null) {
169+
process.exitCode = result.data.run.exitCode ?? 1;
170+
} else {
171+
process.exitCode = 1;
172+
}
168173
}
169174
},
170175
);

0 commit comments

Comments
 (0)