Skip to content
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

:etas not working when width exceeds terminal width #187

Open
AlbertEmil opened this issue Dec 27, 2018 · 1 comment
Open

:etas not working when width exceeds terminal width #187

AlbertEmil opened this issue Dec 27, 2018 · 1 comment

Comments

@AlbertEmil
Copy link

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).

@damiano-carradori
Copy link

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 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants