node-progress
node-progress copied to clipboard
`:etas` not working when width exceeds terminal width
Trying to use :etas
to display the remaining seconds until completion does not work when progress bar is auto-limited by an exceeding column/terminal width:
'use strict';
const ProgressBar = require('progress');
// will show duplicate `s` at end of line (`s` indicating seconds)
const foo = new ProgressBar('Processing [:bar] :percent :etas s', { total: 100 });
// so correct code line would be (as shown in the docs/examples)
// const foo = new ProgressBar('Processing [:bar] :percent :etas', { total: 100 });
let timerFoo = setInterval( () => {
foo.tick();
if (foo.complete) {
clearInterval(timerFoo);
}
}, 10);
// will show duplicate `s` at end of line (`s` indicating seconds)
const name = 'someName';
const bar = new ProgressBar(`Processing '${name}': [:bar] :percent :etas s`, { total: 100 });
// so correct code line would be (as shown in the docs/examples)
// const bar = new ProgressBar(`Processing '${name}': [:bar] :percent :etas`, { total: 100 });
let timerBar = setInterval( () => {
bar.tick();
if (bar.complete) {
clearInterval(timerBar);
}
}, 10);
// will NOT show duplicate `s` at end of line (`s` indicating seconds), so additional `s` is required for correct output
// example given at `https://github.com/visionmedia/node-progress/blob/master/examples/toolong.js`
// does not give correct output either
const baz = new ProgressBar('Detecting [:bar] :percent :etas s', { total: 1000 });
let timerBaz = setInterval( () => {
baz.tick();
if (baz.complete) {
clearInterval(timerBaz);
}
}, 10);
Final output is:
Processing [====================================================================================================] 100% 0.0s s
Processing 'someName': [====================================================================================================] 100% 0.0s s
Detecting [=============================================================================================================================================================] 100% 0.0s
Using progress
v2.0.3 with NodeJS v10.9.0 on MacOS 10.10.5 (did not test on other systems).
Hey Albert, the right code to display the remaining time is :eta
without the s
, so let's try to write :eta s
that will solve the duplicate second unit in you code 😉