1 | import * as Config from '.';
|
2 | export interface Hooks {
|
3 | [event: string]: object;
|
4 | init: {
|
5 | id: string | undefined;
|
6 | argv: string[];
|
7 | };
|
8 | prerun: {
|
9 | Command: Config.Command.Class;
|
10 | argv: string[];
|
11 | };
|
12 | postrun: {
|
13 | Command: Config.Command.Class;
|
14 | result?: any;
|
15 | argv: string[];
|
16 | };
|
17 | preupdate: {
|
18 | channel: string;
|
19 | };
|
20 | update: {
|
21 | channel: string;
|
22 | };
|
23 | 'command_not_found': {
|
24 | id: string;
|
25 | };
|
26 | 'plugins:preinstall': {
|
27 | plugin: {
|
28 | name: string;
|
29 | tag: string;
|
30 | type: 'npm';
|
31 | } | {
|
32 | url: string;
|
33 | type: 'repo';
|
34 | };
|
35 | };
|
36 | }
|
37 | export declare type HookKeyOrOptions<K> = K extends (keyof Hooks) ? Hooks[K] : K;
|
38 | export declare type Hook<T> = (this: Hook.Context, options: HookKeyOrOptions<T> & {
|
39 | config: Config.IConfig;
|
40 | }) => any;
|
41 | export declare namespace Hook {
|
42 | type Init = Hook<Hooks['init']>;
|
43 | type PluginsPreinstall = Hook<Hooks['plugins:preinstall']>;
|
44 | type Prerun = Hook<Hooks['prerun']>;
|
45 | type Postrun = Hook<Hooks['postrun']>;
|
46 | type Preupdate = Hook<Hooks['preupdate']>;
|
47 | type Update = Hook<Hooks['update']>;
|
48 | type CommandNotFound = Hook<Hooks['command_not_found']>;
|
49 | interface Context {
|
50 | config: Config.IConfig;
|
51 | exit(code?: number): void;
|
52 | error(message: string | Error, options?: {
|
53 | code?: string;
|
54 | exit?: number;
|
55 | }): void;
|
56 | warn(message: string): void;
|
57 | log(message?: any, ...args: any[]): void;
|
58 | debug(...args: any[]): void;
|
59 | }
|
60 | }
|