Sequoia / clijs

Nodeschool lesson-set for learning to build shell tools with javascript
GNU General Public License v3.0
5 stars 0 forks source link

Progress bars? #8

Open Sequoia opened 9 years ago

Sequoia commented 9 years ago

This would be hard to write a test for...

This lib is probably the best candidate: Progress: https://github.com/Sequoia/radioechoes-downloader/blob/master/scraper.js#L67-L76 this one's pretty simple.

Currently seeking ideas on how to test this, would love to have a lesson for this cuz progress bars are pretty razzle dazzle.

Sequoia commented 9 years ago

Actually this seems doable . . . progress just grabs stderr and writes to it each tick. It would take some messing around with but it probably shouldn't be too hard to know what to expect from a module outputting a progress bar.

As for what to base the output on. . . I'm inclined to just say a count to 10 in 200ms increments, e.g.

var bar = new ProgressBar(':bar', { total: 10 });
var timer = setInterval(function () {
  bar.tick();
  if (bar.complete) {
    console.log('\ncomplete\n');
    clearInterval(timer);
  }
}, 100);

like the docs example (but swirled up so users can't just c/p it :yum:)