From a2f62de615f3c3aeba464f88f19dd8d520d7f423 Mon Sep 17 00:00:00 2001 From: Hank Duan Date: Mon, 4 Aug 2014 18:29:45 -0700 Subject: [PATCH] fix issue where color formatting text is leaking See https://github.com/angular/protractor/issues/1131 --- lib/launcher.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/launcher.js b/lib/launcher.js index a33d153..74a071a 100644 --- a/lib/launcher.js +++ b/lib/launcher.js @@ -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]; }