Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix on Windows #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix on Windows #6

wants to merge 1 commit into from

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)

@@ -98,7 +97,7 @@ function commentLine (line) {

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