Skip to content

Conversation

Mirantus
Copy link

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.

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.
@bbert
Copy link

bbert commented Oct 9, 2018

I would suggest to use the regular expression /[\r\n]+/g to detect end of lines:

const sourceByLine = source.split(/[\r\n]+/g)

module.exports = function (source) {
try {
const sourceByLine = source.split(os.EOL)
const sourceByLine = source.split('\n')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to use regular /[\r\n]+/g to detect end of lines on all systems

const sourceByLine = source.split(/[\r\n]+/g)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants