GithubHelp home page GithubHelp logo

node-progress's People

Contributors

bahmutov avatar bentruyman avatar brollb avatar commonraven avatar configurator avatar davglass avatar dineshs91 avatar eirikurn avatar frewsxcv avatar hallas avatar hughsk avatar jdan avatar jeetiss avatar kmsheng avatar larshp avatar mleguen avatar nullivex avatar pomax avatar quimcalpe avatar simme avatar sjfkai avatar thebigredgeek avatar themasch avatar tj avatar trenskow avatar westwood846 avatar zzarcon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-progress's Issues

On Windows 7, the console doesn't show properly.

[info] Fetching xulrunner, 53375323 bytes from ftp.mozilla.org
downloading [------------------------------------------------------------------------------------------------------------------------------] 0% 4.8s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 2104.8s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 3987.1s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 3886.0s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 5180.5s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 6477.6s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 6614.1s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 7716.8s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 8820.7s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 9923.4s
downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 11026.1s
downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 12127.7s
downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 13231.5s

downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 15435.9s
downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 16539.7s
downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 16650.0s
downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 11319.3s
downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 11180.0s
downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 11057.0s
downloading [--------------------------------------------------------------------------------------------------------------------------] 0% 10193.8s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 9759.8s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 9080.8s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 9086.8s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 8732.9s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 8588.0s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 8849.1s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 8136.9s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 8043.2s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 8202.7s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 7879.8s
downloading [---------------------------------------------------------------------------------------------------------------------------] 0% 7861.5s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 0% 7897.5s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 0% 7828.9s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 0% 7963.6s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 0% 7847.4s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 0% 7832.8s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 0% 8002.8s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 0% 7983.9s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 0% 8010.6s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 8036.2s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 8192.4s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 8084.0s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 7863.4s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 7927.7s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 7951.5s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 8128.4s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 8304.9s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 8481.8s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 8658.3s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 8835.2s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9012.1s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9188.6s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9365.5s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9496.4s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 8982.3s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9024.8s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9145.7s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9306.7s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9224.3s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9301.2s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9456.3s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9490.6s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9643.6s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9796.6s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9826.4s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9815.3s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9804.7s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9832.8s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9977.5s
downloading [=--------------------------------------------------------------------------------------------------------------------------] 1% 9925.7s
downloading [=-------------------------------------------------------------------------------------------------------------------------] 1% 10067.5s

ETA bug

Wrong math:

replace eta = elapsed * (1 - (this.curr / this.total))

to eta = elapsed * (this.total / this.curr - 1);

Removal of cursor

The cursor can sometimes be really annoying especially in long running progress bars is there a way to remove it

Bar characters that have length longer than one (for example utf-8 pile of poo or added ASCII colors) cause an error

progress/lib/node-progress.js:131
  incomplete = Array(width - complete.length).join(this.chars.incomplete);
               ^
RangeError: Invalid array length
  at ProgressBar.render progress/lib/node-progress.js:131:16)

basically this is caused because the length of incomplete is calculated by taking the string length of complete:

  incomplete = Array(width - complete.length).join(this.chars.incomplete);

Readline behavior issues on darwin

I am running darwin(10.8.4) and [email protected]

I am seeing inconsistent behavior that results generally in the progress bar staying on one line for the first few seconds then it seemingly stops clearing the line and just outputs numerous progress bars one after another sometimes stopping to behave normally again (with the wall of progress bar text above and around it) as if the clearLine function was not being called some or most of the time.

When I removed the darwin specific code in the clearLine function and left it to only call this.write(null, {ctrl: true, name: 'u'}); the progress bar behaved as expected.

Feature request: total should not be required

Just an idea:
Using the progress bar for a simple counter - if total not set :percent etc. would not make sense but :current could still be useful:

  var buildbar = new ProgressBar('Build run (x:current)', {
    // total: 9999 // Would be nice if we didn't have to set this
  });

  // Add a tick every time the server boots
  runForever(program.host, program.port, function() {
    buildbar.tick(1);
  });

refer npm install

This is not a issue at all =), but more a request to add the information about installation using npm to the 'readme'.
AFAIK, this module is called progress and new version progress2 in the npm database,

thanks.
Patrick Marques

running the example in the README, doesn't work on windows

(using cygwin)

$ node test.js


events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: read ENOTCONN
    at errnoException (net.js:901:11)
    at Socket._read (net.js:391:21)
    at Socket.Readable.read (_stream_readable.js:320:10)
    at Socket.read (net.js:293:43)
    at new Socket (net.js:185:10)
    at process.stdin (node.js:660:19)
    at new ProgressBar (C:\cygwin64\home\Thomas Anderson\hyperloop\node_modules\progress\lib\node-progress.js:42:19)
    at ClientRequest.<anonymous> (C:\cygwin64\home\Thomas Anderson\hyperloop\test.js:14:13)
    at ClientRequest.EventEmitter.emit (events.js:95:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1669:21)

seems to be related to setting up process.stdin in readline.

works fine under normal windows console.

Calling .resume() on readline makes scripts hang

In .terminate(), you call this.rl.resume(), which AFAICT calls process.stdin.resume() since you're wrapping process.stdin

This makes scripts not exit on their own, because they're waiting for more input to appear on stdin.

Any reason for calling this? (If anything I'd imagine on terminate you'd want to call this.rl.pause())

next steps

@jdan and everyone else, do you have good suggestions on where to take this for version 2?

so far:

  • comprehensive tests ASAP
  • api to enable management by other tty programs?

v1.1

once we've cleaned up the issues, i'll publish version 1.1 on npm

On Windows this produces a new line for each tick()

Output looks like this on cmd.exe
[====--------------------------------------------] 10%
[=========---------------------------------------] 20%
[==============----------------------------------] 30%
[===================-----------------------------] 40%
[========================------------------------] 50%
[=============================-------------------] 60%
[==================================--------------] 70%
[=======================================---------] 80%
[============================================----] 90%
[=================================================] 100%

Progress isn't working correctly (terminal issue and/or .update issue)

With this code of mine:

var bar = new ProgressBar('  :status [:bar] :percent :etas', { total: 100 });
// Later as part of a `request()` call
    .pipe(progressStream({time: 100}))
    .on('progress', function(p) {
        bar.update(p.progress / 100, {status: 'Downloading'});
    })

I get this result:
screen shot 2015-03-02 at 7 59 53 pm

First problem. Bar updates appear on new lines instead of being updated. Perhaps an incompatibility with OSX's terminal.

Second problem. There is currently a bug with request+progress-stream when gzip is in use (as in my case) that causes the progress event to not know what the actual progress is and as a result have to report progress: 0 until the end when it can finally report one progress: 100.

This means the bar should stay at 0% the whole time and then jump all the way to 100%. However this bar is instead incrementing by one tick each time as if it's completely ignoring the argument to .update.

scaling the bar length so that it fits on the terminal

If I have a progressbar that needs to tick 500 times, I cannot seem to tell progress that I need a bar with total: 500, but visual size 50, for instance. It just creates 500 dashes that it replaces with equal signs. Did I miss something in the readme, or is this not currently supported?

Add default options

Options could as a minimum default to an empty object, or maybe we should warn if required options are missing.

For example if you start the progress bar with no options, it will fail on line 42 in the main library because of options being null, and we're trying to reference options.stream.

EventEmitter leak

I've noticed having more than 10 progress bars in one CLI triggers an event-emitter leak. Traced it to the readline module and I'm not sure how/if I can increase the limit there.

not working in node v0.10.22 ?

This module does not work at all for me on osx, first in the render method this line evaluates to true: if (!this.stream.isTTY) return; (my stream is process.stdout).

I removed that line to debug, and next it broke on this.stream.clearLine(); because clearLine does not appear to be a method on writeable streams in node. I couldn't find what version it was removed in :P

Add a token for custom text

Would it be possible to add a token that would not be updated by the progress bar itself but by the user? it would be doing something like:

var bar = new ProgressBar(':bar :custom', { total: 10 });
bar.render();
// later
bar.custom('here is my custom text');

the timer starts only after the first tick

the progress bar does not compute / report the :elapsed correctly.

bar = new progressBar (
' progress [:bar] :elapsed',
total : 10,
width : 10,
callback : function ()
{
process.exit(0);
}
);

setInterval(
function () { bar.tick(); }.
5000);

will report completion in 45 seconds, as opposed to 50 seconds (10 ticks x 5 seconds).

Publish new version

Hi TJ,

I just wanted to fix the >= issue which was in the version I downloaded yesterday from npm as package. I just noticed when I wanted to send the PR that this is already fixed in the repo.

Can you please publish the new version to npm?

This would also close #20 and #21

Thanks,

Robert

Usage in documentation should specify the API methods

I wanted to display the progress bar before having the first tick(), therefore I looked up in the code to see that I could use render() to do it. I think it would be nice to have the methods in the README file like the options and tokens.

Completed progress bar does ends but no prompt is shown

Hi, I've succesfully implemented a progress bar to show progress on what will be a substantial download. It works great but after finishing it does not release the terminal and seems to hang. The only way to get a prompt back is by hitting ctrl+c. I tried calling console.log('\n'); and console.log(); and sys.puts('download complete'); in the res.on('end', function(){...}); but no luck. Any ideas?

12:46:13 ~/Sites/branches/node-onboarding: node vm.js
downloading [=================================================] 100% 0.0s

Download completed.

Thank you

off-by-one error causes Node to hang after progress is complete (0.1.0 regression)

This is a regression in 0.1.0 from 0.0.5.

Since progress now uses readline, it resumes stdin when you start your bar and tries to pause it again (via this.rl.close()) when the bar is complete. However, due to an off-by-one error, it doesn't actually call this.rl.close until 1 tick past total. So if you are using progress in a simple command-line tool which otherwise doesn't use stdin, using progress 0.1.0 means that stdin will be left resumed and your program will hang. For example, the following program:

var ProgressBar = require('progress');
var bar = new ProgressBar(':bar', {total: 2});
bar.tick();

hangs with 0.1.0 but not with 0.0.5.

The simplest fix for this would be to change the // progress complete code from

  if ((this.curr += len) > this.total) {

to

  if ((this.curr += len) >= this.total) {

However, it seems unfortunate that progress has to interact with stdin at all. Maybe just don't use readline? Or instead of passing process.stdin to readline, pass a dummy object that ignores the methods that are called on it?

I'm happy to submit a pull request to do any of the above, depending on which makes most sense to you.

readline isn't being closed

readline needs to be closed at the end or the program doesn't exit, tried doing bar.rl.close() but doesn't seem to help :(

Multiple progress bars

I'm wondering if node-progress can support multiple progress bars. I have found a gist showing show how to do so but I think it's good it can be built in the lib.

Thanks

No compatible version for Windows 8.1 Update 1

npm ERR! Error: No compatible version found: progress@'^1.1.5'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.0.4","0.0.5","0.1.0","1.0.0","1.0.1","1.1.0
","1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.1.7","1.1.8"]
npm ERR!     at installTargetsError (C:\Program Files (x86)\nodejs\node_modules\
npm\lib\cache.js:682:10)
npm ERR!     at C:\Program Files (x86)\nodejs\node_modules\npm\lib\cache.js:597:
10
npm ERR!     at saved (C:\Program Files (x86)\nodejs\node_modules\npm\node_modul
es\npm-registry-client\lib\get.js:138:7)
npm ERR!     at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program File
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Users\user.domain\Downloads\openwapp-1815a3ce730d100b64d7
3044c1986b069d48ef12.tar\openwapp.git
npm ERR! node -v v0.8.22
npm ERR! npm -v 1.2.14

1.1.5 regression

the 1.1.5 version of progress (which isn't actually a tag on github?) has a horrible regression where instead of updating the bar in place, it prints a new bar for every tick.

Exception thrown if readline.terminal is false

A CLI tool was controlled as part of a grunt process. For whatever reason, this caused the terminal flag to be set to false.

node-progress.js:114 has the is the following line:
this.rl.write(null, {ctrl: true, name: 'u'});

When terminal is false, node throws an exception because it has an explicit check for undefined, but not for null. When terminal is true, node is using a more general check.

Changing the line to:
this.rl.write(undefined, {ctrl: true, name: 'u'});

appears to address the issue without affecting the progress bar.

Incorrect progress bar display

tick() is always showing "[2K" characters before bar string. I've changed this line in tick():

this.stream.write('\r\033[2K' + str);
to
this.stream.write('\r\033' + str);

Works well.

[email protected], node 0.8.8, MacOS X 10.8.1

Error when using shippable

I'm getting this error when used progress inside a service called Shippable. (a CI server)
I'm using [email protected].
What should be the issue?

/usr/lib/node_modules/mup/node_modules/nodemiral/node_modules/progress/lib/node-progress.js:168
this.stream.clearLine();
^
TypeError: Object # has no method 'clearLine'
at ProgressBar.terminate (/usr/lib/node_modules/mup/node_modules/nodemiral/node_modules/progress/lib/node-progress.js:168:17)
at ProgressBar.tick (/usr/lib/node_modules/mup/node_modules/nodemiral/node_modules/progress/lib/node-progress.js:91:10)
at ProgressBar.update (/usr/lib/node_modules/mup/node_modules/nodemiral/node_modules/progress/lib/node-progress.js:157:8)

colors causes error

var colors = require("colors");
var ProgressBar = require("progress");

var bar = new ProgressBar(":bar", {complete:"=".green, total:100});
bar.tick(10);
bar.tick(50);
bar.tick(100);

causes

/project/node_modules/progress/lib/node-progress.js:131
  incomplete = Array(width - complete.length).join(this.chars.incomplete);
               ^
RangeError: Invalid array length
    at ProgressBar.render (/project/node_modules/progress/lib/node-progress.js:131:16)
    at ProgressBar.tick (/project/node_modules/progress/lib/node-progress.js:86:8)
    at Object.<anonymous> (/project/lib/index.js:6:5)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

Not showing

Does the terminal need to have any special settings? Using zsh...

Nothing happens when I use the example in the repo.

nodejs child_process.spawn: no progress bar output

The progress bar works totally fine when I run my node script like this:

node somefile -c someconfig

However, if I do the same with .spawn(), the task works, but I don't see any progress bar output.

My task prints things to the console via Winston logger's console transport.

Here is what I see:

node tasks/users_1.js --config config.local
Warning!>Warning! This will drop all user data! Are you sure?> y
info: Dropped users..
info: Processing 93647 records..
info: 
done
info: Processing xxxx meta key, found 93640 records..
(progress bar should be here)

"Fatal Error: Invalid Array length" if mac terminal window is to small

Hi there,

we just found an error in the "node-progress" module. If you print out the current progress of a file upload using grunt-ssh the progressbar throws an error if the mac terminal window is to small.

We tracked the error down to the node-progress module in version 1.1.6.
In line 127 it is possible for the width to become a negative value.
We fixed this by wrapping the variable assignment with a "Math.max(value, 0)"

Old line:

var width = Math.min(this.width, availableSpace);

New line:

var width = Math.max(Math.min(this.width, availableSpace), 0);

It would be great if this could be implemented.

wider-than-term progress bar works well in windows, doesn't properly update on OSX

on OSX if I use a progress bar that's wider than the terminal I'm running my script in the progress bar doesn't update in place, but instead writes new lines every time it updates, so that I get something like

[-----]
[=----]
[==---]
[===--]
[====-]

which for a 100 element progress bar means 100 lines of screen clutter =(

On windows, this seems to work just fine, the progress bar updates in place and then disappears once it's full.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.