Skip to content

Commit 46866c2

Browse files
committed
fix issue where color formatting text is leaking
See angular#1131
1 parent 316961c commit 46866c2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/launcher.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,23 @@ TaskReporter_.prototype.log_ = function(data) {
305305
tag += (' #' + this.task.taskId);
306306
tag += '] ';
307307

308-
309308
data = data.toString();
310309
for ( var i = 0; i < data.length; i++ ) {
311310
if (this.insertTag) {
312311
this.insertTag = false;
312+
// This ensures that the '\x1B[0m' appears before the tag, so that
313+
// data remains correct when color is not processed.
314+
// See https://github.com/angular/protractor/pull/1216
315+
if (data[i] === '\x1B' && data.substring(i, i+4) === '\x1B[0m' ) {
316+
this.buffer += ('\x1B[0m' + tag);
317+
i += 3;
318+
continue;
319+
}
320+
313321
this.buffer += tag;
314322
}
315323
if (data[i] === '\n') {
316324
this.insertTag = true;
317-
this.buffer += '\x1B[0m'; // Prevent color from leaking into next line
318325
}
319326
this.buffer += data[i];
320327
}

0 commit comments

Comments
 (0)