diff --git a/packages/api/src/interfaces/plugin.ts b/packages/api/src/interfaces/plugin.ts index 94c38379..a5427c58 100644 --- a/packages/api/src/interfaces/plugin.ts +++ b/packages/api/src/interfaces/plugin.ts @@ -1,20 +1,22 @@ -import { Container } from "@ms/container"; - export namespace plugin { /** * MiaoScript Plugin */ export const Plugin = Symbol("Plugin"); + /** + * MiaoScript Plugin + */ + export const PluginFolder = Symbol("PluginFolder"); /** * Runtime Plugin Instance */ export const PluginInstance = Symbol("PluginInstance"); /** - * MiaoScript Plugin Manager + * MiaoScript Plugin Manager Symbol */ export const PluginManager = Symbol("PluginManager"); /** - * MiaoScript Plugin Manager + * MiaoScript Plugin Manager Interface */ export interface PluginManager { scan(folder: string): void; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 793455a8..c860a2af 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -12,6 +12,8 @@ class MiaoScriptCore { private Console: Console; @inject(task.TaskManager) private taskManager: task.TaskManager; + @inject(plugin.PluginFolder) + private pluginFolder: string; @inject(plugin.PluginManager) private pluginManager: plugin.PluginManager; @@ -38,7 +40,7 @@ class MiaoScriptCore { loadPlugins() { let loadPluginStartTime = new Date().getTime() console.log(`Initialization MiaoScript Plugin System. Please wait...`) - this.pluginManager.scan('plugins'); + this.pluginManager.scan(this.pluginFolder); this.pluginManager.build(); this.pluginManager.load(); this.pluginManager.enable(); @@ -78,6 +80,7 @@ function initialize() { let corePackageStartTime = new Date().getTime() container.bind(ContainerInstance).toConstantValue(container); container.bind(plugin.PluginInstance).toConstantValue(base.getInstance()); + container.bind(plugin.PluginFolder).toConstantValue('plugins'); let type = detectServer(); console.info(`Detect Compatible Server set ServerType to ${type} ...`) container.bind(server.ServerType).toConstantValue(type);