From 07a9adbce25e42dcd4d1eb25ee011328d0543304 Mon Sep 17 00:00:00 2001 From: V Date: Tue, 13 Jun 2023 02:36:25 +0200 Subject: 🧹🧹 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/generatePluginList.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'scripts/generatePluginList.ts') diff --git a/scripts/generatePluginList.ts b/scripts/generatePluginList.ts index 87c32ab..70dc142 100644 --- a/scripts/generatePluginList.ts +++ b/scripts/generatePluginList.ts @@ -171,8 +171,8 @@ async function parseFile(fileName: string) { throw fail("no default export called 'definePlugin' found"); } -async function getEntryPoint(dirent: Dirent) { - const base = join("./src/plugins", dirent.name); +async function getEntryPoint(dir: string, dirent: Dirent) { + const base = join(dir, dirent.name); if (!dirent.isDirectory()) return base; for (const name of ["index.ts", "index.tsx"]) { @@ -186,13 +186,23 @@ async function getEntryPoint(dirent: Dirent) { throw new Error(`${dirent.name}: Couldn't find entry point`); } +function isPluginFile({ name }: { name: string; }) { + if (name === "index.ts") return false; + return !name.startsWith("_") && !name.startsWith("."); +} + (async () => { parseDevs(); - const plugins = readdirSync("./src/plugins", { withFileTypes: true }).filter(d => d.name !== "index.ts"); - const promises = plugins.map(async dirent => parseFile(await getEntryPoint(dirent))); + const plugins = ["src/plugins", "src/plugins/_core"].flatMap(dir => + readdirSync(dir, { withFileTypes: true }) + .filter(isPluginFile) + .map(async dirent => + parseFile(await getEntryPoint(dir, dirent)) + ) + ); - const data = JSON.stringify(await Promise.all(promises)); + const data = JSON.stringify(await Promise.all(plugins)); if (process.argv.length > 2) { writeFileSync(process.argv[2], data); -- cgit