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

Added 'useCRLF' option #49

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

Conversation

evergreen-lee-campbell
Copy link

Added a 'useCRLF' option to prevent a new linefeed appearing every time the gulp task is run on Windows machines.

Resolves #42

@coveralls
Copy link

coveralls commented Jul 8, 2016

Coverage Status

Coverage decreased (-0.6%) to 97.484% when pulling fab0d05 on evergreen-lee-campbell:master into 38e66fd on VFK:master.

@VFK
Copy link
Owner

VFK commented Jul 10, 2016

@evergreen-lee-campbell Thank you for your contribution.
I really can't reproduce #42 I created test files with Windows Notepad and Sublime Text with "windows line endings" options and no matter how many times i run this plugin i don't see additional linefeeds. Maybe i'm doing something wrong though so i guess we can do something like your PR. But i have some questions:

  1. If the whole difference is that one \r in regex, could something like this:
/(\r?\n?)([ \t]*)(<!--\s*build:(\w+(?:-\w+)*)\s*-->)\n?([\s\S]*?)\n?(<!--\s*endbuild\s*-->)\n?/ig

or

/(\n?|\r\n?)([ \t]*)(<!--\s*build:(\w+(?:-\w+)*)\s*-->)\n?([\s\S]*?)\n?(<!--\s*endbuild\s*-->)\n?/ig

just work without any new config options? Could you test it please?
2. Could you change tabs to 4 spaces please? Formatting is pretty broken.

@UncleBill
Copy link

I like this option. And I already use @evergreen-lee-campbell 's repository in my package.json.

@aschekatihin
Copy link

aschekatihin commented Mar 15, 2017

Notepad and sublime aren't attempting to do line endings normalization and basically ok with mixed LF and CRLF in one file. But if one using Visual Studio or there is a git autocrlf then there is an extra lines problem.

Regexp that solved problem for me:
var regex = /(\n|\r\n)?([ \t]*)(<!--\s*build:(\w+(?:-\w+)*)\s*-->)([\s\S]*?)(<!--\s*endbuild\s*-->)(\n|\r\n)?/ig;

@chaijunkun
Copy link

I have tried, modified my local dependent version as what @evergreen-lee-campbell committed. it works fine! why @VFK doesn't merge it to master and release it?

@chaijunkun
Copy link

chaijunkun commented Jan 31, 2019

I wrote a test case project as below:
https://github.com/chaijunkun/gulp_test

  1. npm install
    2.npm test

template file is from src/index.html, and output file is dist/index.html.
in macOS, there will be two 0x0a (s) between the two tags:

endbuild
build:seg_2

but in Windows, the character 0x0a presents 3 times between the two tags.

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.

None yet

6 participants