Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/cli/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@ export function isSpinnerEnabled(stream: NodeJS.WriteStream): boolean {

// withLoading — wraps an async fn with a Braille spinner on stream (stderr).
// TTY-false path: zero writes, zero overhead, fn result passed through unchanged.
// This is an UNCONDITIONAL no-op — we never paint a spinner into a pipe,
// regardless of FORCE_COLOR. Animated cursor returns into a non-TTY would
// corrupt downstream consumers (logs, captured stdout, CI buffers).
// TTY-true path: still honors isSpinnerEnabled so NO_COLOR / FORCE_COLOR=0 can suppress.
// TTY-true path: initial frame written before interval, cleanup in finally.
// Result<T, E> transparency: never wraps, unwraps, or catches fn's value (R12).
export async function withLoading<T>(
stream: NodeJS.WriteStream,
fn: () => Promise<T>,
options?: WithLoadingOptions,
): Promise<T> {
if (stream.isTTY !== true) {
return fn();
}
if (!isSpinnerEnabled(stream)) {
return fn();
}
Expand Down
Loading