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

double line #33

Closed
pabloalmunia opened this issue Jan 8, 2015 · 6 comments
Closed

double line #33

pabloalmunia opened this issue Jan 8, 2015 · 6 comments
Labels

Comments

@pabloalmunia
Copy link

The first "include" create a double return per line.

The followings "include" don't have this problem.

This is the original file:

utils.uuid = function uuid(a){
    return a ?
        (a ^ Math.random()*16 >> a/4).toString(16) :
        ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,this.uuid);
};

This is the file included:

            utils.uuid = function uuid(a){

                return a ?

                    (a ^ Math.random()*16 >> a/4).toString(16) :

                    ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,this.uuid);

            };
@mehtmehtsen
Copy link

gulp-include seems to have a problem with the line endings. I just "included" a file with CR and LF for line endings, in the final file there are two lines per line.
So in Notepad++ I replaced \r\n (CRLF) with \r (CR) and recompiled. Everything's fine now. Funny thing: when I just use LFs, I also get two lines.
So I suppose your first file uses CRLF or maybe just LF, the others use CRs.

@rikjurjens
Copy link

The problem seems to be with the DIRECTIVE_REGEX.
There are no problems if you use it like this:

(function() {
    //= include file.js
    //= include file2.js
})();

But when you start adding newlines. It will start adding two newlines after each line in your include file.

(function() {

    //= include file.js

    //= include file2.js

})();

@zefirka
Copy link

zefirka commented Jun 29, 2015

I think the trouble on line 79, where:
whitespace = whitespace[0].replace("\n", "");
This clears only first \n from whitespace matches, when for first include it equals to '\n\n', so after it expression whitespace is truthy (when we except false).

I've made pull reques.

@wiledal
Copy link
Owner

wiledal commented Jun 30, 2015

This is fixed in the new version. Closing!

@wiledal wiledal closed this as completed Jun 30, 2015
@Skosiris
Copy link

@wiledal Getting double lines on v2.0.2 (Windows) on any require/include command that is preceded by empty lines.

ex: The footer here gets double lines.

//=include inc/page-header.inc

test page

//=include inc/page-footer.inc

Adding something right before the include fixes the problem:

//=include inc/page-header.inc

test page

something
//=include inc/page-footer.inc

@jelmerdemaat
Copy link
Contributor

I'm also getting this issue with version 2.0.2 on Windows. Solved for now by removing blank lines in front of //=include statements. But permanent solution would be great!

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

No branches or pull requests

7 participants