Closed ghwilson4456 closed 9 years ago
Those newlines are giving me headaches, but for this the solutions seems to be simple enough. I'll scan the first file to detect the type of end-line and apply that to the join. I'll have a try at it this in the weekend.
I've improved the line endings for your use case, but it's untested. Could you confirm it works for you? Unit tests are required, I hope to add them eventually.
My issue was somehow similar to @ghwilson4456 problem, the lines that were joined were all \n instead of \r\n in windows. The problem is evident in these lines, https://github.com/jwvdiermen/grunt-include-source/blob/master/tasks/includeSource.js#L261-L264. After a line feed \n is detected, it decrements the index, the problem is at https://github.com/jwvdiermen/grunt-include-source/blob/master/tasks/includeSource.js#L262, wherein you check for the decremented index minus 1.
Change:
if (contents[i] === '\n'){
i--;
if (contents[i-1] === '\r'){
i--;
}
break;
}
to:
if (contents[i] === '\n'){
if (contents[--i] === '\r'){
i--;
}
break;
}
This should be fixed in the latest release.
Running wiredep after doing an includeSource breaks my index.html, but only on Windows machines. Works fine in OS X. Changing line 204 of includeSource.js to .join('\r\n'); fixes the issue.