You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- inline this.#render logic. The initial setTimeout is only used during
load(), so run it there instead.
- .unref() the progress bar's recurring timeout object
- reuse the progress bar's timeout object with .refresh() instead of
making a new one every frame
- Minor comment syntax cleanup and remove stale comments
- skip clearing the line on the first frame when resuming the spinner
- removed the test from #8631 as it was only testing that the very first
frame of the spinner didn't clear the line, not any subsequent frames
This is built off of #8631, moving the
"skip clearing the line..." logic into a flag that's passed during
.resume()
// we get the chalk level based on a null stream meaning chalk will only use what it knows about the environment to get color support since we already determined in our definitions that we want to show colors.
223
+
// We get the chalk level based on a null stream, meaning chalk will only use what it knows about the environment to get color support since we already determined in our definitions that we want to show colors.
// Silent mode and some specific commands always hide run script banners
314
312
break
315
313
}elseif(this.#json){
316
314
// In json mode, change output to stderr since we don't want to break json parsing on stdout if the user is piping to jq or something.
317
-
// XXX: in a future (breaking?) change it might make sense for run-script to always output these banners with proc-log.output.error if we think they align closer with "logging" instead of "output"
315
+
// XXX: in a future (breaking?) change it might make sense for run-script to always output these banners with proc-log.output.error if we think they align closer with "logging" instead of "output".
318
316
level=output.KEYS.error
319
317
}
320
318
}
@@ -339,12 +337,12 @@ class Display {
339
337
break
340
338
341
339
caseinput.KEYS.read: {
342
-
// The convention when calling input.read is to pass in a single fn that returns the promise to await. resolve and reject are provided by proc-log
340
+
// The convention when calling input.read is to pass in a single fn that returns the promise to await. resolve and reject are provided by proc-log.
343
341
const[res,rej,p]=args
344
342
returninput.start(()=>p()
345
343
.then(res)
346
344
.catch(rej)
347
-
// Any call to procLog.input.read will render a prompt to the user, so we always add a single newline of output to stdout to move the cursor to the next line
345
+
// Any call to procLog.input.read will render a prompt to the user, so we always add a single newline of output to stdout to move the cursor to the next line.
// Wait 200 ms so we don't render the spinner for short durations
448
+
this.#timeout =setTimeout(()=>{
449
+
this.#timeout =null
450
+
this.#render()
451
+
},200)
452
+
// Make sure this timeout does not keep the process open
453
+
this.#timeout.unref()
450
454
}
451
455
452
456
off(){
@@ -463,7 +467,7 @@ class Progress {
463
467
}
464
468
465
469
resume(){
466
-
this.#render()
470
+
this.#render(true)
467
471
}
468
472
469
473
// If we are currently rendering the spinner we clear it before writing our line and then re-render the spinner after.
@@ -478,45 +482,43 @@ class Progress {
478
482
}
479
483
}
480
484
481
-
#render (ms){
482
-
if(ms){
483
-
this.#timeout =setTimeout(()=>{
484
-
this.#timeout =null
485
-
this.#renderSpinner()
486
-
},ms)
487
-
// Make sure this timeout does not keep the process open
488
-
this.#timeout.unref()
489
-
}else{
490
-
this.#renderSpinner()
491
-
}
492
-
}
493
-
494
-
#renderSpinner (){
485
+
#render (resuming){
495
486
if(!this.#rendering){
496
487
return
497
488
}
498
489
// We always attempt to render immediately but we only request to move to the next frame if it has been longer than our spinner frame duration since our last update
0 commit comments