aboutsummaryrefslogtreecommitdiff
path: root/scripts/generatePluginList.ts
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-06-13 02:36:25 +0200
committerV <vendicated@riseup.net>2023-06-13 03:45:05 +0200
commit07a9adbce25e42dcd4d1eb25ee011328d0543304 (patch)
treec4ea6230e57cc3a77adc53c25efb91ea148a6dea /scripts/generatePluginList.ts
parent42d8211871d84e2650f7c762c66e2ee2e6c58968 (diff)
downloadVencord-07a9adbce25e42dcd4d1eb25ee011328d0543304.tar.gz
Vencord-07a9adbce25e42dcd4d1eb25ee011328d0543304.tar.bz2
Vencord-07a9adbce25e42dcd4d1eb25ee011328d0543304.zip
🧹🧹
Diffstat (limited to 'scripts/generatePluginList.ts')
-rw-r--r--scripts/generatePluginList.ts20
1 files changed, 15 insertions, 5 deletions
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);