From ce80d7e883580e784a720235397f68ab9d14f4e8 Mon Sep 17 00:00:00 2001 From: JackGruber <24863925+JackGruber@users.noreply.github.com> Date: Thu, 13 May 2021 09:54:27 +0200 Subject: [PATCH] Generator: Fixed issue with handling of CRLF in ignore file (#4956) --- packages/generator-joplin/generators/app/utils.js | 2 +- packages/generator-joplin/generators/app/utils.test.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/generator-joplin/generators/app/utils.js b/packages/generator-joplin/generators/app/utils.js index 258f9375a..fe9eaaa35 100644 --- a/packages/generator-joplin/generators/app/utils.js +++ b/packages/generator-joplin/generators/app/utils.js @@ -41,7 +41,7 @@ function mergePackageKey(parentKey, source, dest) { } function mergeIgnoreFile(source, dest) { - const output = dest.trim().split('\n').concat(source.trim().split('\n')); + const output = dest.trim().split(/\r?\n/).concat(source.trim().split(/\r?\n/)); return `${output.filter(function(item, pos) { if (!item) return true; // Leave blank lines diff --git a/packages/generator-joplin/generators/app/utils.test.js b/packages/generator-joplin/generators/app/utils.test.js index 82ecc8845..88bb3b7a1 100644 --- a/packages/generator-joplin/generators/app/utils.test.js +++ b/packages/generator-joplin/generators/app/utils.test.js @@ -33,6 +33,9 @@ describe('utils', () => { const testCases = [ ['line1\nline2\n', 'newline\n', 'line1\nline2\nnewline\n'], ['line1\nline2\n', 'line1\nnewline\n', 'line1\nline2\nnewline\n'], + ['line1\r\nline2\r\n', 'line1\nnewline\n', 'line1\nline2\nnewline\n'], + ['line1\nline2\n', 'line1\r\nnewline\r\n', 'line1\nline2\nnewline\n'], + ['line1\r\nline2\r\n', 'line1\r\nnewline\r\n', 'line1\nline2\nnewline\n'], ]; for (const t of testCases) {