-
Notifications
You must be signed in to change notification settings - Fork 149
feat(spinner): add clear param to stop function #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
@example/basic • @example/changesets commit: |
bc53d86 to
5aae76b
Compare
|
my concern here is the signature doesn't align anymore: const stop = (msg = '', code = 0, clear = false): void
i wonder if we should have a thoughts @dreyfus92 ? |
If we follow the #401 suggestion, this will break |
|
hey peeps, i agree with @43081j. it would be best to create a export interface SpinnerResult {
start(msg?: string): void;
stop(msg?: string, code?: number): void;
clear(code?: boolean): void; // NEW: silently stops spinner
message(msg?: string): void;
readonly isCancelled: boolean;
} |
can you explain why it would break the progress prompt? could we not just add |
If we change the BEFORE: const stop = (msg = '', code = 0): void => {
if (!isSpinnerActive) return;
isSpinnerActive = false;
clearInterval(loop);
clearPrevMessage();
const step =
code === 0
? color.green(S_STEP_SUBMIT)
: 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`);
}
clearHooks();
unblock();
};AFTER: - const stop = (msg = '', code = 0): void => {
+ const stop = (msg, code = 0): void => {
if (!isSpinnerActive) return;
isSpinnerActive = false;
clearInterval(loop);
clearPrevMessage();
const step =
code === 0
? color.green(S_STEP_SUBMIT)
: 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 (msg != null) {
+ _message = msg;
+ if (indicator === 'timer') {
+ output.write(`${step} ${_message} ${formatTimer(_origin)}\n`);
+ } else {
+ output.write(`${step} ${_message}\n`);
+ }
}
clearHooks();
unblock();
};When we run the test (maybe we must update the test): Snapshots 28 failed
Test Files 2 failed | 12 passed (14)
Tests 28 failed | 356 passed (384)
Start at 13:18:24
Duration 15.13s (transform 5.40s, setup 0ms, collect 29.24s, tests 10.29s, environment 48ms, prepare 19.68s)
In some spinner libraries, |
|
i wonder if we should try land that first, then add a the one other popular spinner (ignoring so i'd be happy to have a |
Fixes #401