feat(plugins): Load plugins from "plugins" folder (#1)

This commit is contained in:
_Sakura 2022-10-21 22:44:24 +09:00 committed by GitHub
parent dc112cfdf4
commit d8827a0097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 11 deletions

View File

@ -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<void> {
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"),
)

View File

@ -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).