1 | import type { WatchOptions } from 'chokidar'
|
2 |
|
3 | export type NodemonEventHandler =
|
4 | | 'start'
|
5 | | 'crash'
|
6 | | 'exit'
|
7 | | 'quit'
|
8 | | 'restart'
|
9 | | 'config:update'
|
10 | | 'log'
|
11 | | 'readable'
|
12 | | 'stdout'
|
13 | | 'stderr';
|
14 |
|
15 | export type NodemonEventListener = {
|
16 | on(event: 'start' | 'crash' | 'readable', listener: () => void): Nodemon;
|
17 | on(event: 'log', listener: (e: NodemonEventLog) => void): Nodemon;
|
18 | on(event: 'stdout' | 'stderr', listener: (e: string) => void): Nodemon;
|
19 | on(event: 'restart', listener: (e?: NodemonEventRestart) => void): Nodemon;
|
20 | on(event: 'quit', listener: (e?: NodemonEventQuit) => void): Nodemon;
|
21 | on(event: 'exit', listener: (e?: number) => void): Nodemon;
|
22 | on(event: 'config:update', listener: (e?: NodemonEventConfig) => void): Nodemon;
|
23 | };
|
24 |
|
25 | export type Nodemon = {
|
26 | removeAllListeners(event: NodemonEventHandler): Nodemon;
|
27 | emit(type: NodemonEventHandler, event?: any): Nodemon;
|
28 | reset(callback: Function): Nodemon;
|
29 | restart(): Nodemon;
|
30 | config: NodemonSettings;
|
31 | } & NodemonEventListener & {
|
32 | [K in keyof NodemonEventListener as "addListener"]: NodemonEventListener[K];
|
33 | } & {
|
34 | [K in keyof NodemonEventListener as "once"]: NodemonEventListener[K];
|
35 | };
|
36 |
|
37 | export type NodemonEventLog = {
|
38 | |
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | type: 'detail' | 'log' | 'status' | 'error' | 'fail';
|
45 |
|
46 | message: string;
|
47 |
|
48 | colour: string;
|
49 | };
|
50 |
|
51 | export interface NodemonEventRestart {
|
52 | matched?: {
|
53 | result: string[];
|
54 | total: number;
|
55 | };
|
56 | }
|
57 |
|
58 | export type NodemonEventQuit = 143 | 130;
|
59 |
|
60 | export type NodemonEventConfig = {
|
61 | run: boolean;
|
62 | system: {
|
63 | cwd: string;
|
64 | };
|
65 | required: boolean;
|
66 | dirs: string[];
|
67 | timeout: number;
|
68 | options: NodemonConfig;
|
69 | lastStarted: number
|
70 | loaded: string[]
|
71 | load: (settings: NodemonSettings, ready: (config: NodemonEventConfig) => void) => void
|
72 | reset: () => void
|
73 | };
|
74 |
|
75 | export interface NodemonExecOptions {
|
76 | script: string;
|
77 | scriptPosition?: number;
|
78 | args?: string[]
|
79 | ext?: string;
|
80 | exec?: string;
|
81 | execArgs?: string[];
|
82 | nodeArgs?: string[];
|
83 | }
|
84 |
|
85 | export interface NodemonConfig {
|
86 |
|
87 | restartable?: false | string;
|
88 | colours?: boolean;
|
89 | execMap?: { [key: string]: string };
|
90 | ignoreRoot?: string[];
|
91 | watch?: string[];
|
92 | ignore?: string[];
|
93 | stdin?: boolean;
|
94 | runOnChangeOnly?: boolean;
|
95 | verbose?: boolean;
|
96 | signal?: string;
|
97 | stdout?: boolean;
|
98 | watchOptions?: WatchOptions;
|
99 | help?: string
|
100 | version?: boolean
|
101 | cwd?: string
|
102 | dump?: boolean
|
103 | ignore?: string[]
|
104 | watch?: string[]
|
105 | monitor?: string[]
|
106 | spawn?: boolean
|
107 | noUpdateNotifier?: boolean
|
108 | legacyWatch?: boolean
|
109 | pollingInterval?: number
|
110 |
|
111 | js?: boolean
|
112 | quiet?: boolean
|
113 | configFile?: string
|
114 | exitCrash?: boolean
|
115 | execOptions?: NodemonExecOptions
|
116 | }
|
117 |
|
118 | export interface NodemonSettings extends NodemonConfig, NodemonExecOptions {
|
119 | events?: { [key: string]: string };
|
120 | env?: { [key: string]: string };
|
121 | }
|
122 |
|
123 | const nodemon: Nodemon = (settings: NodemonSettings): Nodemon => {};
|
124 |
|
125 | export = nodemon;
|