Simplify and correct newlines replacement logic on Windows (#1713)

This commit is contained in:
Regin Larsen 2017-04-05 14:37:04 +02:00 committed by Albin Ekblom
parent 7a64c9ee8a
commit ec18537d96

View file

@ -88,7 +88,7 @@ function exec(str) {
// to text formatted with DOS line endings. We do this because the default // to text formatted with DOS line endings. We do this because the default
// text editor on Windows (notepad) doesn't Deal with LF files. Still. In 2017. // text editor on Windows (notepad) doesn't Deal with LF files. Still. In 2017.
function crlfify(str) { function crlfify(str) {
return str.split('\n').map(x => x.indexOf('\r') < 0 ? x : `${x}\r`).join('\n'); return str.replace(/\r?\n/g, '\r\n');
} }
exports.subscribe = function (fn) { exports.subscribe = function (fn) {