Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On OSX revert back to terminal hack to avoid a readline bug #15

Merged
merged 1 commit into from Sep 19, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/node-progress.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand All @@ -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);
};