Commit 98405ccc authored by nanahira's avatar nanahira

run command action at last

parent cf12428d
Pipeline #6153 passed with stages
in 1 minute and 13 seconds
{ {
"name": "koishi-nestjs", "name": "koishi-nestjs",
"version": "1.0.29", "version": "1.0.30",
"description": "Koishi.js as Nest.js Module", "description": "Koishi.js as Nest.js Module",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
......
...@@ -83,9 +83,8 @@ export class KoishiMetascanService { ...@@ -83,9 +83,8 @@ export class KoishiMetascanService {
); );
break; break;
case 'onevent': case 'onevent':
const { const { data: eventData } =
data: eventData, regData as DoRegisterConfig<EventNameAndPrepend>;
} = regData as DoRegisterConfig<EventNameAndPrepend>;
baseContext.on(eventData.name, (...args: any[]) => baseContext.on(eventData.name, (...args: any[]) =>
methodFun.call(instance, ...args), methodFun.call(instance, ...args),
); );
...@@ -106,11 +105,7 @@ export class KoishiMetascanService { ...@@ -106,11 +105,7 @@ export class KoishiMetascanService {
const { data: commandData } = regData as DoRegisterConfig< const { data: commandData } = regData as DoRegisterConfig<
ContextFunction<Command> ContextFunction<Command>
>; >;
let command = commandData( let command = commandData(baseContext);
baseContext,
).action((argv: Argv, ...args: any[]) =>
methodFun.call(instance, argv, ...args),
);
const commandDefs: CommandDefinitionFun[] = this.reflector.get( const commandDefs: CommandDefinitionFun[] = this.reflector.get(
KoishiCommandDefinition, KoishiCommandDefinition,
methodFun, methodFun,
...@@ -120,6 +115,9 @@ export class KoishiMetascanService { ...@@ -120,6 +115,9 @@ export class KoishiMetascanService {
command = commandDef(command) || command; command = commandDef(command) || command;
} }
} }
command.action((argv: Argv, ...args: any[]) =>
methodFun.call(instance, argv, ...args),
);
break; break;
default: default:
throw new Error(`Unknown operaton type ${regData.type}`); throw new Error(`Unknown operaton type ${regData.type}`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment