Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed; erase the line when complete

  • Loading branch information...
commit 6e10e368c72eb79f9785ed8528b245dc6249204f 1 parent 684f627
@tj authored
Showing with 3 additions and 7 deletions.
  1. +1 −6 examples/formats.js
  2. +2 −1  lib/node-progress.js
View
7 examples/formats.js
@@ -7,12 +7,11 @@ var ProgressBar = require('../');
var bar = new ProgressBar(':bar :title', { total: 10 });
-console.log('processing:');
+console.log();
var id = setInterval(function(){
var randomTitle = ['some', 'random', 'title'][Math.random() * 3 | 0];
bar.tick({ title: randomTitle });
if (bar.complete) {
- console.log('\ncomplete\n');
clearInterval(id);
bar2();
}
@@ -28,7 +27,6 @@ function bar2() {
var id = setInterval(function(){
bar.tick();
if (bar.complete) {
- console.log('\n');
clearInterval(id);
bar3();
}
@@ -46,7 +44,6 @@ function bar3() {
var id = setInterval(function(){
bar.tick();
if (bar.complete) {
- console.log('\n');
clearInterval(id);
bar4();
}
@@ -61,7 +58,6 @@ function bar4() {
var id = setInterval(function(){
bar.tick();
if (bar.complete) {
- console.log('\n');
clearInterval(id);
bar5();
}
@@ -77,7 +73,6 @@ function bar5() {
var id = setInterval(function(){
bar.tick();
if (bar.complete) {
- console.log('\n');
clearInterval(id);
}
}, 300);
View
3  lib/node-progress.js
@@ -78,6 +78,7 @@ ProgressBar.prototype.tick = function(len, tokens){
// progress complete
if ((this.curr += len) >= this.total) {
this.complete = true;
+ this.stream.write('\r\033[2K');
return;
}
@@ -104,5 +105,5 @@ ProgressBar.prototype.tick = function(len, tokens){
}
}
- this.stream.write('\r\x1b[2K' + str);
+ this.stream.write('\r\033[2K' + str);
};
Please sign in to comment.
Something went wrong with that request. Please try again.