diff --git a/components/controller.ts b/components/controller.ts index 8bc1b7f5..d8107047 100644 --- a/components/controller.ts +++ b/components/controller.ts @@ -869,11 +869,23 @@ export class Controller { } /** - * Loads all normal, pre-built or pure JS plugins. + * Loads all normal, pre-built or pure JS plugins either from root or plugins folder. * * @internal */ private async _loadPlugins(): Promise { + if (existsSync("plugins")) { + const entries = ( + await readdir(join(process.cwd(), "plugins")) + ).filter((n) => isPlugin(n, "js") || isPlugin(n, "cjs")) + + for (const plugin of entries) { + const sourceFile = join(process.cwd(), "plugins", plugin) + const src = (await readFile(sourceFile)).toString() + + await this._executePlugin(plugin, src, sourceFile) + } + } const entries = (await readdir(process.cwd())).filter( (n) => isPlugin(n, "js") || isPlugin(n, "cjs"), ) diff --git a/packaging/README.md b/packaging/README.md index 8b869c5e..d43523bf 100644 --- a/packaging/README.md +++ b/packaging/README.md @@ -3,13 +3,13 @@ This folder contains some tools related to the build/packaging/deployment infrastructure of the project. -- `build.mjs` - The esbuild configuration for the server in production. -- `buildTasks.mjs` - Pre-bundling of specific files. -- `devLoader.mjs` - Starts the server in the development environment. -- `esbuild-plugin-license.mjs` - esbuild plugin that automatically updates the - THIRDPARTYNOTICES.txt file. -- `extractChallengeData.mjs` - a little CLI tool for downloading challenges from - the IOI servers. -- `HOW_TO_USE.html` - legacy help file. -- `json5ToJson.mjs` - Converts a JSON5 file to a JSON file with the same name ( - but the JSON extension). +- `build.mjs` - The esbuild configuration for the server in production. +- `buildTasks.mjs` - Pre-bundling of specific files. +- `devLoader.mjs` - Starts the server in the development environment. +- `esbuild-plugin-license.mjs` - esbuild plugin that automatically updates the + THIRDPARTYNOTICES.txt file. +- `extractChallengeData.mjs` - a little CLI tool for downloading challenges from + the IOI servers. +- `HOW_TO_USE.html` - legacy help file. +- `json5ToJson.mjs` - Converts a JSON5 file to a JSON file with the same name ( + but the JSON extension).