Closed abrown28 closed 3 years ago
well it works the first time I go through a start, update, and stop cycle but the next time it's still set to the old stopTime. I guess creating a new progress bar instead of reusing the old one would probably fix it for me.
Hi @abrown28
thanks for your contribution but your code doesn't make any sense since stopTime
is already set in the next loc
I'm probably not using it in the way you want but here is some example code
const progress = require("cli-progress")
async function test() {
const progressBar = new progress.SingleBar({
format: '{message} | {bar} | {percentage}% || {value}/{total} records || {duration} || {duration_formatted} || {eta_formatted}',
}, progress.Presets.shades_classic);
for(let i=0; i<10; ++i) {
progressBar.start(100, 0, {
message: "Testing progress bar when reused"
})
for(let j=0; j<100; ++j) {
progressBar.update(j+1)
await sleep(1)
}
progressBar.stop();
}
}
async function sleep(seconds) {
return new Promise(resolve => setTimeout(resolve, seconds*100));
}
test()
When I run the above I get the following:
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 11 || 11s || 0s
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 0 || 0s || 0s
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 0 || 0s || 0s
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 0 || 0s || 0s
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 0 || 0s || 0s
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 0 || 0s || 0s
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 0 || 0s || 0s
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 0 || 0s || 0s
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 0 || 0s || 0s
Testing progress bar when reused | ████████████████████████████████████████ | 100% || 100/100 records || 0 || 0s || 0s
The duration and duration_formatted only worked the first time. That's what I'm seeing when I pull it with npm
the fix has already been provided in https://github.com/npkgz/cli-progress/pull/101 but it's not release yet
v3.9.1 is out including the changes within master (patch #101 )
ah gotcha. I missed that :)
Thanks
On Wed, Sep 15, 2021 at 4:20 AM Andi Dittrich @.***> wrote:
v3.9.1 is out including the changes within master (patch #101 https://github.com/npkgz/cli-progress/pull/101 )
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/npkgz/cli-progress/pull/110#issuecomment-919849125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAUEQQ7YTT2U5LXCKJL3ODUCBQNFANCNFSM5D5YSO6Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
--
Alex Brown @.***
Duration was not working for me. I fixed it by setting stopTime to null.