From 00f6a8da3bb3d780f7ef79b448ae0caebc90c11e Mon Sep 17 00:00:00 2001 From: Mirantus Date: Tue, 19 Dec 2017 13:03:26 +0700 Subject: [PATCH] Fix on Windows It's doesnt work on Windows when files have file encodings with '\n'. os.EOL returns '\n\r' so we have array sourceByLine as one string instead of multivalues. Then commentCodeInsideBlocks can't find this big string in truthyBlocks and nothing do. --- src/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index dcdad5b..b8322ae 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,4 @@ /* eslint-disable no-eval */ -const os = require('os'); function getPredicate (line) { return /\/\/ #if (.*)/.exec(line)[1] @@ -98,7 +97,7 @@ function commentLine (line) { module.exports = function (source) { try { - const sourceByLine = source.split(os.EOL) + const sourceByLine = source.split('\n') const blocks = searchBlocks(sourceByLine) const truthyBlocks = getTruthyBlocks(blocks) const transformedSource = commentCodeInsideBlocks(sourceByLine, truthyBlocks)