Files
directus/packages/cli/src/events.ts
renovate[bot] b2ec182493 Update typescript-eslint monorepo to v5 (major) (#8702)
* Update typescript-eslint monorepo to v5

* Fix linter warnings

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-10-12 11:07:46 -04:00

26 lines
909 B
TypeScript

import { Command } from './command';
import { IOutput } from './output';
export type Listener<T = any, P = any, R = any> =
| ((...args: P[]) => Promise<R>)
| ((...args: P[]) => R)
| ((this: T, ...args: P[]) => Promise<R>)
| ((this: T, ...args: P[]) => R);
export type EventTypes = {
'command.initialize.before': (command: Command) => void | Promise<void>;
'command.initialize.after': (command: Command) => void | Promise<void>;
'command.execute.before': (command: Command, options: any) => void | Promise<void>;
'command.execute.after': (command: Command) => void | Promise<void>;
'command.options.register': (command: Command) => void;
'output.formats.register': (output: IOutput) => void;
};
export interface IEvents {
on<E extends keyof EventTypes>(event: E, listener: EventTypes[E]): void;
emit<E extends keyof EventTypes>(event: E, ...args: Parameters<EventTypes[E]>): Promise<void>;
}