Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #15 from davglass/readline-osx

On OSX revert back to terminal hack to avoid a readline bug
  • Loading branch information...
commit f0e396365b4476c004e247ad85b7826229f36131 2 parents 5a12caf + a269bd6
@tj authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 lib/node-progress.js
View
13 lib/node-progress.js
@@ -47,6 +47,13 @@ function ProgressBar(fmt, options) {
output: options.stream || process.stdout
});
this.rl.setPrompt('', 0);
+ this.rl.clearLine = function() {
+ if (process.platform === 'darwin') {
+ this.output.write('\r');
+ } else {
+ this.write(null, {ctrl: true, name: 'u'});
+ }
+ };
options = options || {};
if ('string' != typeof fmt) throw new Error('format required');
@@ -83,7 +90,7 @@ ProgressBar.prototype.tick = function(len, tokens){
// progress complete
if ((this.curr += len) > this.total) {
this.complete = true;
- //this.rl.write(null, {ctrl: true, name: 'u'});
+ this.rl.clearLine();
this.rl.resume();
this.rl.close();
return;
@@ -110,7 +117,7 @@ ProgressBar.prototype.tick = function(len, tokens){
str = str.replace(':' + key, tokens[key]);
}
}
-
- this.rl.write(null, {ctrl: true, name: 'u'});
+
+ this.rl.clearLine();
this.rl.write(str);
};
Please sign in to comment.
Something went wrong with that request. Please try again.