feat: use fewer system resources to draw the progress bar

There's reason to believe that upgrade scripts will run faster
if the system isn't spending a non-insignificant amount of
resources simply drawing the progress bar. Closes #7711

Some context: https://github.com/npm/npm/issues/11283
v1.18.x
Julian Lam 6 years ago
parent f0703e21c5
commit d0ee312cd3

@ -204,7 +204,8 @@ Upgrade.process = function (files, skipCount, callback) {
Upgrade.incrementProgress = function (value) {
this.current += value || 1;
// Redraw the progress bar
// Redraw the progress bar every 100 units
if (this.current % 100 === 0) {
var percentage = 0;
var filled = 0;
var unfilled = 15;
@ -216,4 +217,5 @@ Upgrade.incrementProgress = function (value) {
readline.cursorTo(process.stdout, 0);
process.stdout.write(' [' + (filled ? new Array(filled).join('#') : '') + new Array(unfilled).join(' ') + '] (' + this.current + '/' + (this.total || '??') + ') ' + percentage + ' ');
}
};

Loading…
Cancel
Save