feat: detect non-TTY environments and disable animations #139
+25
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR improves the CLI's behavior in non-interactive environments by automatically detecting TTY contexts and disabling animations, while also refactoring user cancellation handling to use proper error flow instead of direct process exits. This prevents rendering issues in CI/CD pipelines and piped output scenarios, while making the codebase more maintainable and testable.
Related Issue
Fixes #138
Type of Change
Changes Made
bin/run.jsandbin/dev.jsto identify non-interactive environmentsCI=truewhen stdin or stdout is not a TTY to disable @clack/prompts animationsCLIExitErrorinstead ofprocess.exit(0)in:src/cli/commands/project/link.ts:66- prompt cancellation handlerssrc/cli/commands/project/link.ts:116- project selection cancellationsrc/cli/utils/prompts.ts:10-onPromptCancelutility functionsrc/cli/utils/runCommand.ts:96to pass throughCLIExitErrorwithout logging (for intentional exits)Testing
npm test)Checklist
Additional Notes
The TTY detection uses Node.js's built-in
process.stdin.isTTYandprocess.stdout.isTTYproperties. SettingCI=trueis a standard convention that @clack/prompts respects to disable animations.The cancellation refactoring improves code quality by using proper error flow (
CLIExitError) instead of directprocess.exit()calls, making the code more testable and maintainable. TherunCommandutility now silently passes throughCLIExitErrorinstances since these represent intentional, graceful exits (e.g., user cancellations).🤖 Generated by Claude | 2026-01-27 22:50 UTC