diff --git a/lib/colors.js b/lib/colors.js index 7a5a980..0b39272 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -105,10 +105,7 @@ function applyStyle() { return str; } - var newLinesPresent = false; - if(str.indexOf('\n') != -1){ - newLinesPresent = true; - } + var newLinesPresent = str.indexOf('\n') != -1; var nestedStyles = this._styles; @@ -116,7 +113,7 @@ function applyStyle() { while (i--) { var code = ansiStyles[nestedStyles[i]]; str = code.open + str.replace(code.closeRe, code.open) + code.close; - if(newLinesPresent){ + if (newLinesPresent){ str = str.replace(newLineRegex, code.close + '\n' + code.open); } }