progress
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -21,3 +21,3 @@ /*! | ||
* - `width` the displayed width of the progress bar defaulting to total | ||
* - `stream` the output stream defaulting to stdout | ||
* - `stream` the output stream defaulting to stderr | ||
* - `complete` completion character defaulting to "=" | ||
@@ -42,5 +42,6 @@ * - `incomplete` incomplete character defaulting to "-" | ||
function ProgressBar(fmt, options) { | ||
this.stream = options.stream || process.stderr; | ||
this.rl = require('readline').createInterface({ | ||
input: process.stdin, | ||
output: options.stream || process.stdout | ||
output: this.stream | ||
}); | ||
@@ -72,2 +73,3 @@ this.rl.setPrompt('', 0); | ||
this.callback = options.callback || function () {}; | ||
this.lastDraw = ''; | ||
} | ||
@@ -115,3 +117,3 @@ | ||
ProgressBar.prototype.render = function(tokens){ | ||
if(!process.stdout.isTTY) { | ||
if (!this.stream.isTTY) { | ||
return; | ||
@@ -146,4 +148,7 @@ } | ||
this.rl.clearLine(); | ||
this.rl.write(str); | ||
if (this.lastDraw !== str) { | ||
this.rl.clearLine(); | ||
this.rl.write(str); | ||
this.lastDraw = str; | ||
} | ||
}; | ||
@@ -150,0 +155,0 @@ |
{ | ||
"name": "progress" | ||
, "version": "1.1.3" | ||
, "version": "1.1.4" | ||
, "description": "Flexible ascii progress bar" | ||
@@ -5,0 +5,0 @@ , "keywords": ["cli", "progress"] |
@@ -32,3 +32,3 @@ # node-progress | ||
- `width` the displayed width of the progress bar defaulting to total | ||
- `stream` the output stream defaulting to stdout | ||
- `stream` the output stream defaulting to stderr | ||
- `complete` completion character defaulting to "=" | ||
@@ -35,0 +35,0 @@ - `incomplete` incomplete character defaulting to "-" |
9334
163