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

Extract getIncludeFile function. NFC #21425

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/jsifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,21 @@ function shouldPreprocess(fileName) {
return content.startsWith('#preprocess\n') || content.startsWith('#preprocess\r\n');
}

function getIncludeFile(fileName, needsPreprocess) {
let result = `// include: ${fileName}\n`;
if (needsPreprocess) {
result += processMacros(preprocess(fileName));
} else {
result += read(fileName);
}
result += `// end include: ${fileName}\n`;
return result;
}

function preJS() {
let result = '';
for (const fileName of PRE_JS_FILES) {
if (shouldPreprocess(fileName)) {
result += processMacros(preprocess(fileName));
} else {
result += read(fileName);
}
result += getIncludeFile(fileName, shouldPreprocess(fileName));
}
return result;
}
Expand Down Expand Up @@ -601,13 +608,7 @@ function(${args}) {
}

function includeFile(fileName, needsPreprocess = true) {
print(`// include: ${fileName}`);
if (needsPreprocess) {
print(processMacros(preprocess(fileName)));
} else {
print(read(fileName));
}
print(`// end include: ${fileName}`);
print(getIncludeFile(fileName, needsPreprocess))
}

function finalCombiner() {
Expand Down
Loading