make bundler more resilient to missing sources

This commit is contained in:
Stewart Allen 2025-10-14 00:33:36 -04:00
commit 1c6a988d27
2 changed files with 9 additions and 1 deletions

7
app.js
View file

@ -196,8 +196,13 @@ function init(mod) {
if (alt) { if (alt) {
for (let [ key, val ] of Object.entries(append)) { for (let [ key, val ] of Object.entries(append)) {
let src = `src/main/${key}.js`;
if (!fs.existsSync(src)) {
logger.log('missing:', src);
continue;
}
fs.mkdirSync(`alt/main`, { recursive: true }); fs.mkdirSync(`alt/main`, { recursive: true });
let body = fs.readFileSync(`src/main/${key}.js`); let body = fs.readFileSync(src);
fs.writeFileSync(`alt/main/${key}.js`, body + val); fs.writeFileSync(`alt/main/${key}.js`, body + val);
} }
} }

View file

@ -14,6 +14,9 @@ function* walk(dir, seen = new Set()) {
if (excludes.indexOf(dir) >= 0) { if (excludes.indexOf(dir) >= 0) {
return; return;
} }
if (!fs.existsSync(dir)) {
return;
}
const real = fs.realpathSync(dir); const real = fs.realpathSync(dir);
if (seen.has(real)) { if (seen.has(real)) {