Skip to content

Commit a99d42c

Browse files
committed
apply suggestion from @43081j's review
1 parent d7121a6 commit a99d42c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/prompts/src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,12 @@ export const spinner = ({ indicator = 'dots', onCancel }: SpinnerOptions = {}) =
746746
const handleExit = (code: number) => {
747747
const msg = code > 1 ? 'Something went wrong' : 'Canceled';
748748
isCancelled = code === 1;
749-
if (isCancelled && typeof onCancel === 'function') {
750-
onCancel();
749+
if (isSpinnerActive) {
750+
stop(msg, code);
751+
if (isCancelled && typeof onCancel === 'function') {
752+
onCancel();
753+
}
751754
}
752-
if (isSpinnerActive) stop(msg, code);
753755
};
754756

755757
const errorEventHandler = () => handleExit(2);

0 commit comments

Comments
 (0)