Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(check-electron): syntax-check electron/ subdirectories too

DeryFerdb21c478f3277
diff --git a/scripts/check-electron.mjs b/scripts/check-electron.mjs
index c94a238116..b25bd37383 100644
--- a/scripts/check-electron.mjs
+++ b/scripts/check-electron.mjs
@@ -7,10 +7,15 @@ import { fileURLToPath } from "node:url";
const electronDirectory = fileURLToPath(new URL("../electron/", import.meta.url));
const require = createRequire(import.meta.url);
const electronExecutable = require("electron");
-const modules = readdirSync(electronDirectory, { withFileTypes: true })
- .filter((entry) => entry.isFile() && /\.(?:cjs|mjs)$/.test(entry.name))
- .map((entry) => path.join(electronDirectory, entry.name))
- .sort();
+/** Every module the app can load at startup, including `app-install/` and `fixtures/`: main.mjs and the installer import
+ * them, so a syntax error there is a crash, not a test failure. `vendor/` is somebody else's code. */
+function modulesIn(directory) {
+ return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
+ if (entry.isDirectory()) return entry.name === "vendor" ? [] : modulesIn(path.join(directory, entry.name));
+ return entry.isFile() && /\.(?:cjs|mjs)$/.test(entry.name) ? [path.join(directory, entry.name)] : [];
+ });
+}
+const modules = modulesIn(electronDirectory).sort();
if (modules.length === 0) throw new Error("No Electron modules were found to syntax-check");
for (const modulePath of modules) {