From 82bbddac8d656b60b3a1fb2471ea03ee5224f5c3 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 13 Sep 2022 22:36:15 +0300 Subject: [PATCH] revert: feat of allow constructable modules (#138) Revert "feat: allow constructable modules (#133)" This reverts commit 03936eb2ea1d1af7cada04d77bb8345d63a5e20f. --- src/handler/events/readyHandler.ts | 2 +- src/handler/events/userDefinedEventsHandling.ts | 2 +- src/handler/utilities/readFile.ts | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/handler/events/readyHandler.ts b/src/handler/events/readyHandler.ts index 83e02dc..1a5318e 100644 --- a/src/handler/events/readyHandler.ts +++ b/src/handler/events/readyHandler.ts @@ -87,7 +87,7 @@ export default class ReadyHandler extends EventsHandler<{ type: PluginType.Command; }[]; }) { - if ((mod.plugins || []).length === 0) { + if (mod.plugins.length === 0) { return of({ mod, pluginRes: [] }); } // modules with no event plugins are ignored in the previous diff --git a/src/handler/events/userDefinedEventsHandling.ts b/src/handler/events/userDefinedEventsHandling.ts index 5293520..fa02698 100644 --- a/src/handler/events/userDefinedEventsHandling.ts +++ b/src/handler/events/userDefinedEventsHandling.ts @@ -25,7 +25,7 @@ export function processCommandPlugins( wrapper: Wrapper, payload: { mod: T; absPath: string }, ) { - return (payload.mod.plugins || []).map(plug => ({ + return payload.mod.plugins.map(plug => ({ ...plug, name: plug?.name ?? 'Unnamed Plugin', description: plug?.description ?? '...', diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index 47497bf..1f12eee 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -73,11 +73,6 @@ export function buildData(commandDir: string): Observable< } catch { mod = (await import(`file:///` + absPath)).default; } - - try { - mod = new (mod as unknown as new (...args: unknown[]) => T)(); - } catch {} - if (mod !== undefined) { return Ok({ mod, absPath }); } else return Err(SernError.UndefinedModule);