UNPKG

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