Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Send cursor commands only if isatty (close #184)

Refael Ackermann98f0430d8219
diff --git a/lib/reporters/base.js b/lib/reporters/base.js
index d8687c72..370aba22 100644
--- a/lib/reporters/base.js
+++ b/lib/reporters/base.js
@@ -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');
+ }
}
};