From 8f9178f9c1bb7f5f8961a63d19e56ef07f0b8567 Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Thu, 25 Apr 2019 11:57:32 +0300 Subject: [PATCH] fix: fix the workflow warnings split on Windows (always split by "\n" as the string literals are always generating "/n" terminating lines based on the below-mentioned ES specification) More details here: http://exploringjs.com/es6/ch_template-literals.html#_line-terminators-in-template-literals-are-always-lf-n 8.2.3 Line terminators in template literals are always LF (\n) # Common ways of terminating lines are: Line feed (LF, \n, U+000A): used by Unix (incl. current macOS) Carriage return (CR, \r, U+000D): used by the old Mac OS. CRLF (\r\n): used by Windows. `All of these line terminators are normalized to LF in template literals.` That is, the following code logs true on all platforms: const str = `BEFORE AFTER`; console.log(str === 'BEFORE\nAFTER'); // true --- lib/common/helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/helpers.ts b/lib/common/helpers.ts index 7283ecb764..5ca4bb5d3f 100644 --- a/lib/common/helpers.ts +++ b/lib/common/helpers.ts @@ -389,7 +389,7 @@ export function getMessageWithBorders(message: string, spanLength = 3): string { return ""; } - const longestRowLength = message.split(EOL).sort((a, b) => { return b.length - a.length; })[0].length; + const longestRowLength = message.split("\n").sort((a, b) => { return b.length - a.length; })[0].length; let border = "*".repeat(longestRowLength + 2 * spanLength); // * 2 for both sides if (border.length % 2 === 0) { border += "*"; // the * should always be an odd number in order to get * in each edge (we will remove the even *s below) @@ -405,7 +405,7 @@ export function getMessageWithBorders(message: string, spanLength = 3): string { EOL, border + EOL, emptyRow, - ...message.split(EOL).map(row => formatRow(row)), + ...message.split("\n").map(row => formatRow(row.trim())), emptyRow, border + EOL, EOL