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) {