UNPKG

1.6 kBTypeScriptView Raw
1declare class UndertakerRegistry {
2 /**
3 * Returns the task with that name or undefined if no task is registered with that name.
4 * Useful for custom task storage.
5 * Custom registries can override this method when inheriting from this default registry.
6 * @param taskName - Name of task.
7 */
8 get<TTaskFunction>(taskName: string): TTaskFunction;
9
10 /**
11 * No-op method that receives the undertaker instance.
12 * Useful to set pre-defined tasks using the undertaker.task(taskName, fn) method.
13 * Custom registries can override this method when inheriting from this default registry.
14 * @param taker - Instance of undertaker.
15 */
16 init(taker: any): void;
17
18 /**
19 * Adds a task to the registry.
20 * If set modifies a task, it should return the new task so Undertaker can properly maintain metadata for the task.
21 * Useful for adding custom behavior to every task as it is registered in the system.
22 * Custom registries can override this method when inheriting from this default registry.
23 * @param taskName - Name of task.
24 * @param fn - Task function.
25 */
26 set<TTaskFunction>(taskName: string, fn: TTaskFunction): TTaskFunction;
27
28 /**
29 * Returns an object listing all tasks in the registry.
30 * Necessary to override if the get method is overridden for custom task storage.
31 * Custom registries can override this when when inheriting from this default registry.
32 */
33 tasks(): { [taskName: string]: (...args: any[]) => any };
34}
35
36declare namespace UndertakerRegistry {}
37
38export = UndertakerRegistry;