Skip to content

Commit

Permalink
Send cursor commands only if isatty (close #184)
Browse files Browse the repository at this point in the history
  • Loading branch information
Refael Ackermann authored and travisjeffery committed Oct 13, 2013
1 parent 34116d5 commit 98f0430
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,28 @@ exports.window = {

exports.cursor = {
hide: function(){
process.stdout.write('\u001b[?25l');
isatty && process.stdout.write('\u001b[?25l');
},

show: function(){
process.stdout.write('\u001b[?25h');
isatty && process.stdout.write('\u001b[?25h');
},

deleteLine: function(){
process.stdout.write('\u001b[2K');
isatty && process.stdout.write('\u001b[2K');
},

beginningOfLine: function(){
process.stdout.write('\u001b[0G');
isatty && process.stdout.write('\u001b[0G');
},

CR: function(){
exports.cursor.deleteLine();
exports.cursor.beginningOfLine();
if (isatty) {
exports.cursor.deleteLine();
exports.cursor.beginningOfLine();
} else {
process.stdout.write('\n');
}
}
};

Expand Down

0 comments on commit 98f0430

Please sign in to comment.