UNPKG

6.28 kBTypeScriptView Raw
1/// <reference types="node" />
2
3export = nodemon;
4
5declare function nodemon(options: nodemon.Settings | string): typeof nodemon;
6
7declare namespace nodemon {
8 function restart(): void;
9
10 function addListener(event: string | symbol, listener: (...args: any[]) => void): typeof nodemon;
11 function addListener(
12 event: "start" | "exit" | "crash" | "config:update" | "readable",
13 listener: () => void,
14 ): typeof nodemon;
15 function addListener(event: "restart", listener: (files?: string[]) => void): typeof nodemon;
16 function addListener(event: "quit", listener: (code?: number) => void): typeof nodemon;
17 function addListener(event: "watching", listener: (file: string) => void): typeof nodemon;
18 function addListener(event: "log", listener: (msg: LogMessage) => void): typeof nodemon;
19 function addListener(event: "stdout" | "stderr", listener: (data: Buffer) => void): typeof nodemon;
20
21 function on(event: string | symbol, listener: (...args: any[]) => void): typeof nodemon;
22 function on(event: "start" | "exit" | "crash" | "config:update" | "readable", listener: () => void): typeof nodemon;
23 function on(event: "restart", listener: (files?: string[]) => void): typeof nodemon;
24 function on(event: "quit", listener: (code?: number) => void): typeof nodemon;
25 function on(event: "watching", listener: (file: string) => void): typeof nodemon;
26 function on(event: "log", listener: (msg: LogMessage) => void): typeof nodemon;
27 function on(event: "stdout" | "stderr", listener: (data: Buffer) => void): typeof nodemon;
28
29 function once(event: string | symbol, listener: (...args: any[]) => void): typeof nodemon;
30 function once(
31 event: "start" | "exit" | "crash" | "config:update" | "readable",
32 listener: () => void,
33 ): typeof nodemon;
34 function once(event: "quit", listener: (code?: number) => void): typeof nodemon;
35 function once(event: "restart", listener: (files?: string[]) => void): typeof nodemon;
36 function once(event: "watching", listener: (file: string) => void): typeof nodemon;
37 function once(event: "log", listener: (msg: LogMessage) => void): typeof nodemon;
38 function once(event: "stdout" | "stderr", listener: (data: Buffer) => void): typeof nodemon;
39
40 function removeAllListeners(event?: string | symbol): typeof nodemon;
41
42 function emit(event: string | symbol, ...args: any[]): boolean;
43 function emit(event: "start" | "exit" | "crash" | "config:update" | "readable"): boolean;
44 function emit(event: "quit", code?: number): boolean;
45 function emit(event: "restart", files?: string[]): boolean;
46 function emit(event: "watching", listener: (file: string) => void): boolean;
47 function emit(event: "log", msg: LogMessage): boolean;
48 function emit(event: "stdout" | "stderr", data: Buffer): boolean;
49
50 function reset(done?: () => void): void;
51
52 interface Settings {
53 env?: { [key: string]: string | boolean | number } | undefined;
54 script?: string | undefined;
55 /**
56 * Extensions to look for, ie. js,jade,hbs.
57 */
58 ext?: string | undefined;
59 /**
60 * Execute script with "app", ie. -x "python -v". May use variables.
61 */
62 exec?: string | undefined;
63 /**
64 * Watch directory or file. One entry per watched value. Wildcards are allowed.
65 */
66 watch?: ReadonlyArray<string | { re: string }> | undefined;
67 /**
68 * Ignore specific files or directories. One entry per ignored value. Wildcards are allowed.
69 */
70 ignore?: ReadonlyArray<string | { re: string }> | undefined;
71 /**
72 * Minimise nodemon messages to start/stop only.
73 */
74 quiet?: boolean | undefined;
75 /**
76 * Show detail on what is causing restarts.
77 */
78 verbose?: boolean | undefined;
79 /**
80 * Try to read from stdin. Set to false to have nodemon pass stdin directly to child process
81 */
82 stdin?: boolean | undefined;
83 stdout?: boolean | undefined;
84 /**
85 * Execute script on change only, not startup
86 */
87 runOnChangeOnly?: boolean | undefined;
88 /**
89 * Debounce restart in seconds.
90 */
91 delay?: number | undefined;
92 /**
93 * Forces node to use the most compatible version for watching file changes.
94 *
95 * Use polling to watch for changes (typically needed when watching over a network/Docker)
96 */
97 legacyWatch?: boolean | undefined;
98 /**
99 * Exit on crash, allows use of nodemon with daemon tools like forever.js.
100 */
101 exitcrash?: boolean | undefined;
102 /**
103 * The global config file is useful for setting up default executables
104 */
105 execMap?: {
106 [k: string]: any;
107 } | undefined;
108 events?: { [key: string]: string } | undefined;
109 restartable?: string | undefined;
110 args?: readonly string[] | undefined;
111 /**
112 * Arguments to pass to node if exec is "node"
113 */
114 nodeArgs?: readonly string[] | undefined;
115 scriptPosition?: number | undefined;
116 /**
117 * Set to false to disable color output
118 */
119 colours?: boolean | undefined;
120 /**
121 * Change into <dir> before running the script
122 */
123 cwd?: string | undefined;
124 /**
125 * Print full debug configuration
126 */
127 dump?: boolean | undefined;
128 /**
129 * Root paths to ignore
130 */
131 ignoreRoot?: string[] | undefined;
132 /**
133 * Opt-out of update version check
134 */
135 noUpdateNotifier?: boolean | undefined;
136 /**
137 * Combined with legacyWatch, milliseconds to poll for (default 100)
138 */
139 pollingInterval?: number | undefined;
140 /**
141 * Use specified kill signal instead of default (ex. SIGTERM)
142 */
143 signal?: string | undefined;
144 /**
145 * Force nodemon to use spawn (over fork) [node only]
146 */
147 spawn?: boolean | undefined;
148 [k: string]: any;
149 }
150
151 interface LogMessage {
152 type: string;
153 message: string;
154 colour: string;
155 }
156}