Skip to content

Commit d3e253d

Browse files
committed
feat(spinner): nothing appear when stop message is undefined
1 parent 69508f4 commit d3e253d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/prompts/src/spinner.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const spinner = ({
163163
}, delay);
164164
};
165165

166-
const stop = (msg = '', code = 0): void => {
166+
const stop = (msg, code = 0): void => {
167167
if (!isSpinnerActive) return;
168168
isSpinnerActive = false;
169169
clearInterval(loop);
@@ -174,12 +174,16 @@ export const spinner = ({
174174
: code === 1
175175
? color.red(S_STEP_CANCEL)
176176
: color.red(S_STEP_ERROR);
177-
_message = msg ?? _message;
178-
if (indicator === 'timer') {
179-
output.write(`${step} ${_message} ${formatTimer(_origin)}\n`);
180-
} else {
181-
output.write(`${step} ${_message}\n`);
182-
}
177+
// If we set `msg` to undefined
178+
if (msg !== undefined) {
179+
// If we set `msg` to null
180+
_message = msg ?? _message;
181+
if (indicator === 'timer') {
182+
output.write(`${step} ${_message} ${formatTimer(_origin)}\n`);
183+
} else {
184+
output.write(`${step} ${_message}\n`);
185+
}
186+
};
183187
clearHooks();
184188
unblock();
185189
};

0 commit comments

Comments
 (0)