aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authormegumin <megumin.bakaretsurie@gmail.com>2022-10-17 22:46:52 +0100
committerGitHub <noreply@github.com>2022-10-17 23:46:52 +0200
commit9d6021f0b985ca09fded65af87166c1f7a70141a (patch)
treefe6245f03a335007e92cadc58268a827ac4c5933 /scripts
parent5a18292d929e35a2d848ff4e1472229d36cd0745 (diff)
downloadVencord-9d6021f0b985ca09fded65af87166c1f7a70141a.tar.gz
Vencord-9d6021f0b985ca09fded65af87166c1f7a70141a.tar.bz2
Vencord-9d6021f0b985ca09fded65af87166c1f7a70141a.zip
feat: gitignored src/userplugins directory (#112)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/common.mjs23
1 files changed, 15 insertions, 8 deletions
diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs
index 59153a6..deb8ff4 100644
--- a/scripts/build/common.mjs
+++ b/scripts/build/common.mjs
@@ -1,5 +1,6 @@
import { execSync } from "child_process";
import esbuild from "esbuild";
+import { existsSync } from "fs";
import { readdir } from "fs/promises";
const watch = process.argv.includes("--watch");
@@ -41,21 +42,27 @@ export const globPlugins = {
});
build.onLoad({ filter: /^plugins$/, namespace: "import-plugins" }, async () => {
- const files = await readdir("./src/plugins");
+ const pluginDirs = ["plugins", "userplugins"];
let code = "";
let plugins = "\n";
- for (let i = 0; i < files.length; i++) {
- if (files[i] === "index.ts") {
- continue;
+ let i = 0;
+ for (const dir of pluginDirs) {
+ if (!existsSync(`./src/${dir}`)) continue;
+ const files = await readdir(`./src/${dir}`);
+ for (const file of files) {
+ if (file === "index.ts") {
+ continue;
+ }
+ const mod = `p${i}`;
+ code += `import ${mod} from "./${dir}/${file.replace(/.tsx?$/, "")}";\n`;
+ plugins += `[${mod}.name]:${mod},\n`;
+ i++;
}
- const mod = `p${i}`;
- code += `import ${mod} from "./${files[i].replace(/.tsx?$/, "")}";\n`;
- plugins += `[${mod}.name]:${mod},\n`;
}
code += `export default {${plugins}};`;
return {
contents: code,
- resolveDir: "./src/plugins"
+ resolveDir: "./src"
};
});
}