Skip to content
Open
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
16 changes: 9 additions & 7 deletions packages/prompts/src/spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface SpinnerOptions extends CommonOptions {

export interface SpinnerResult {
start(msg?: string): void;
stop(msg?: string, code?: number): void;
stop(msg?: string, code?: number, clear?: boolean): void;
message(msg?: string): void;
readonly isCancelled: boolean;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ export const spinner = ({
}, delay);
};

const stop = (msg = '', code = 0): void => {
const stop = (msg = '', code = 0, clear = false): void => {
if (!isSpinnerActive) return;
isSpinnerActive = false;
clearInterval(loop);
Expand All @@ -174,11 +174,13 @@ export const spinner = ({
: code === 1
? color.red(S_STEP_CANCEL)
: color.red(S_STEP_ERROR);
_message = msg ?? _message;
if (indicator === 'timer') {
output.write(`${step} ${_message} ${formatTimer(_origin)}\n`);
} else {
output.write(`${step} ${_message}\n`);
if (!clear) {
_message = msg ?? _message;
if (indicator === 'timer') {
output.write(`${step} ${_message} ${formatTimer(_origin)}\n`);
} else {
output.write(`${step} ${_message}\n`);
}
}
clearHooks();
unblock();
Expand Down
Loading