Skip to content

Commit b82d6e8

Browse files
Fix CLI crash in non-TTY environments (fixes #122) (#123)
Guard interactive mode behind `isInteractive` flag (`!options.ci && process.stdout.isTTY && process.stdin.isTTY`), which also unifies the CI path and the non-TTY auto-detection into a single branch. In non-interactive mode, live progress renders are suppressed and the final result tree is printed once before exiting with the correct code. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c9368c0 commit b82d6e8

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/env/node.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,21 @@ export default {
129129
process.env.NODE_ENV = "test";
130130
},
131131
done (result, options, event, root) {
132-
if (options.ci) {
132+
// Interactive mode requires both a TTY stdout (for cursor control) and a TTY stdin (for raw keypress events).
133+
// The --ci flag explicitly opts into non-interactive mode regardless of TTY state.
134+
let isInteractive = !options.ci && process.stdout.isTTY && process.stdin.isTTY;
135+
136+
if (!isInteractive) {
133137
if (root.stats.pending === 0) {
134138
if (root.stats.fail > 0 || options.verbose) {
135139
let messages = root.toString(options);
136140
let tree = getTree(messages).toString();
137141
tree = format(tree);
138142

139143
console[root.stats.fail > 0 ? "error" : "log"](tree);
140-
process.exit(root.stats.fail > 0 ? 1 : 0);
141144
}
142145

143-
process.exit(0);
146+
process.exit(root.stats.fail > 0 ? 1 : 0);
144147
}
145148
}
146149
else {

0 commit comments

Comments
 (0)