This commit is contained in:
Alex Dima
2020-10-06 22:18:15 +02:00
parent 2d6d4a328a
commit 443508c4c9
9 changed files with 87 additions and 29 deletions

View File

@@ -149,7 +149,7 @@ export abstract class Command {
*
* @return `true` if the command was successfully run. This stops other overrides from being executed.
*/
export type CommandImplementation = (accessor: ServicesAccessor, args: unknown) => boolean;
export type CommandImplementation = (accessor: ServicesAccessor, args: unknown) => boolean | Promise<void>;
export class MultiCommand extends Command {
@@ -175,8 +175,12 @@ export class MultiCommand extends Command {
public runCommand(accessor: ServicesAccessor, args: any): void | Promise<void> {
for (const impl of this._implementations) {
if (impl[1](accessor, args)) {
return;
const result = impl[1](accessor, args);
if (result) {
if (typeof result === 'boolean') {
return;
}
return result;
}
}
}