Skip to content

Commit a9aa709

Browse files
authored
Minor cleanups to preprocess function. NFC (#18617)
1 parent 3b3d791 commit a9aa709

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/parseTools.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function preprocess(filename) {
4545
.replace(/\bimport\.meta\b/g, 'EMSCRIPTEN$IMPORT$META')
4646
.replace(/\bawait import\b/g, 'EMSCRIPTEN$AWAIT$IMPORT');
4747
}
48+
// Remove windows line endings, if any
49+
text = text.replace(/\r\n/g, '\n');
4850

4951
const IGNORE = 0;
5052
const SHOW = 1;
@@ -65,21 +67,19 @@ function preprocess(filename) {
6567

6668
try {
6769
for (let [i, line] of lines.entries()) {
68-
if (line[line.length - 1] === '\r') {
69-
line = line.substr(0, line.length - 1); // Windows will have '\r' left over from splitting over '\r\n'
70-
}
71-
if (isHtml && line.includes('<style') && !inStyle) {
72-
inStyle = true;
73-
}
74-
if (isHtml && line.includes('</style') && inStyle) {
75-
inStyle = false;
76-
}
77-
78-
if (inStyle) {
79-
if (showCurrentLine()) {
80-
ret += line + '\n';
70+
if (isHtml) {
71+
if (line.includes('<style') && !inStyle) {
72+
inStyle = true;
73+
}
74+
if (line.includes('</style') && inStyle) {
75+
inStyle = false;
76+
}
77+
if (inStyle) {
78+
if (showCurrentLine()) {
79+
ret += line + '\n';
80+
}
81+
continue;
8182
}
82-
continue;
8383
}
8484

8585
const trimmed = line.trim();

0 commit comments

Comments
 (0)