diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 7ae5962..b5bcfa2 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -28,17 +28,20 @@ export function onReady(wrapper: Wrapper) { }); }), map(({ mod, absPath }) => { - return { - name: mod?.name ?? Files.fmtFileName(basename(absPath)), - description: mod?.description ?? '...', - ...mod, + return { + absPath, + mod: { + name: mod?.name ?? Files.fmtFileName(basename(absPath)), + description: mod?.description ?? '...', + ...mod, + }, }; }), ); const processPlugins$ = processCommandFiles$.pipe( - concatMap(mod => { - const cmdPluginRes = processCommandPlugins(wrapper, mod); - return of({ mod, cmdPluginRes }); + concatMap(payload => { + const cmdPluginRes = processCommandPlugins(wrapper, payload); + return of({ mod: payload.mod, cmdPluginRes }); }), ); diff --git a/src/handler/events/userDefinedEventsHandling.ts b/src/handler/events/userDefinedEventsHandling.ts index c898e7b..0ceb0b8 100644 --- a/src/handler/events/userDefinedEventsHandling.ts +++ b/src/handler/events/userDefinedEventsHandling.ts @@ -13,14 +13,17 @@ import { errTap } from './observableHandling'; /** * Utility function to process command plugins for all Modules * @param wrapper - * @param mod + * @param payload */ -export function processCommandPlugins(wrapper: Wrapper, mod: T) { - return mod.plugins.map(plug => ({ +export function processCommandPlugins( + wrapper: Wrapper, + payload: { mod: T; absPath: string }, +) { + return payload.mod.plugins.map(plug => ({ ...plug, name: plug?.name ?? 'Unnamed Plugin', description: plug?.description ?? '...', - execute: plug.execute(wrapper, mod, controller), + execute: plug.execute(wrapper, payload, controller), })); } diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 078443e..359cc5f 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -44,7 +44,10 @@ export type CommandPlugin, + payload: { + mod: DefinitelyDefined; + absPath: string; + }, controller: Controller, ) => Awaitable>; }