Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix issue where color formatting text is leaking
Browse files Browse the repository at this point in the history
See #1131
  • Loading branch information
hankduan committed Aug 20, 2014
1 parent 96994d0 commit 9814af1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,23 @@ TaskReporter_.prototype.log_ = function(data) {
tag += (' #' + this.task.taskId);
tag += '] ';


data = data.toString();
for ( var i = 0; i < data.length; i++ ) {
if (this.insertTag) {
this.insertTag = false;
// This ensures that the '\x1B[0m' appears before the tag, so that
// data remains correct when color is not processed.
// See https://github.com/angular/protractor/pull/1216
if (data[i] === '\x1B' && data.substring(i, i+4) === '\x1B[0m' ) {
this.buffer += ('\x1B[0m' + tag);
i += 3;
continue;
}

this.buffer += tag;
}
if (data[i] === '\n') {
this.insertTag = true;
this.buffer += '\x1B[0m'; // Prevent color from leaking into next line
}
this.buffer += data[i];
}
Expand Down

0 comments on commit 9814af1

Please sign in to comment.