aboutsummaryrefslogtreecommitdiff
path: root/scripts/build/common.mjs
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-11-21 18:46:09 +0100
committernea <romangraef@gmail.com>2022-11-21 21:50:46 +0100
commit7b5c8c9cd3256bf1041024176bba6b748a4638da (patch)
tree74c8388dd2660c5644f74971997ce505664a1006 /scripts/build/common.mjs
parent0d4d020affa62ee8ff1cc327970352a691cfd246 (diff)
downloadVencord-7b5c8c9cd3256bf1041024176bba6b748a4638da.tar.gz
Vencord-7b5c8c9cd3256bf1041024176bba6b748a4638da.tar.bz2
Vencord-7b5c8c9cd3256bf1041024176bba6b748a4638da.zip
UserPlugins: Add clickable badges to external user pluginsfeat/userpluginbadge
This patch adds a button to each user plugin (this is determined by the plugin directory). Additionally user plugins can specify an `externalLink` in their plugin definition to have their badge be clickable and link to an external website. Co-Authored-By: exhq <91651232+exhq@users.noreply.github.com>
Diffstat (limited to 'scripts/build/common.mjs')
-rw-r--r--scripts/build/common.mjs16
1 files changed, 10 insertions, 6 deletions
diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs
index 11aaa81..35af0f4 100644
--- a/scripts/build/common.mjs
+++ b/scripts/build/common.mjs
@@ -60,19 +60,23 @@ export const globPlugins = {
});
build.onLoad({ filter, namespace: "import-plugins" }, async () => {
- const pluginDirs = ["plugins", "userplugins"];
+ const pluginDirs = [
+ { dir: "plugins", official: true },
+ { dir: "userplugins", official: false },
+ ];
let code = "";
let plugins = "\n";
let i = 0;
- for (const dir of pluginDirs) {
- if (!existsSync(`./src/${dir}`)) continue;
- const files = await readdir(`./src/${dir}`);
- for (const file of files) {
+ for (const pluginDirectory of pluginDirs) {
+ const pluginPath = `./src/${pluginDirectory.dir}`;
+ if (!existsSync(pluginPath)) continue;
+ for (const file of await readdir(pluginPath)) {
if (file === "index.ts") {
continue;
}
const mod = `p${i}`;
- code += `import ${mod} from "./${dir}/${file.replace(/.tsx?$/, "")}";\n`;
+ code += `import ${mod} from "./${pluginDirectory.dir}/${file.replace(/.tsx?$/, "")}";\n`;
+ code += `${mod}['isUserPlugin'] = ${!pluginDirectory.official};`;
plugins += `[${mod}.name]:${mod},\n`;
i++;
}