| [81bc7da] | 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: (files?: string[]) => void): Nodemon;
|
|---|
| 20 | on(event: 'quit', listener: (e?: NodemonEventQuit) => void): Nodemon;
|
|---|
| 21 | on(event: 'exit', listener: (e?: number) => void): Nodemon;
|
|---|
| 22 | on(
|
|---|
| 23 | event: 'config:update',
|
|---|
| 24 | listener: (e?: NodemonEventConfig) => void,
|
|---|
| 25 | ): Nodemon;
|
|---|
| 26 | };
|
|---|
| 27 |
|
|---|
| 28 | export type NodemonEventLog = {
|
|---|
| 29 | /**
|
|---|
| 30 | - detail: what you get with nodemon --verbose.
|
|---|
| 31 | - status: subprocess starting, restarting.
|
|---|
| 32 | - fail: is the subprocess crashing.
|
|---|
| 33 | - error: is a nodemon system error.
|
|---|
| 34 | */
|
|---|
| 35 | type: 'detail' | 'log' | 'status' | 'error' | 'fail';
|
|---|
| 36 | /** the plain text message */
|
|---|
| 37 | message: string;
|
|---|
| 38 | /** contains the terminal escape codes to add colour, plus the "[nodemon]" prefix */
|
|---|
| 39 | colour: string;
|
|---|
| 40 | };
|
|---|
| 41 |
|
|---|
| 42 | export type NodemonEventQuit = 143 | 130;
|
|---|
| 43 |
|
|---|
| 44 | export type NodemonEventConfig = {
|
|---|
| 45 | run: boolean;
|
|---|
| 46 | system: {
|
|---|
| 47 | cwd: string;
|
|---|
| 48 | };
|
|---|
| 49 | required: boolean;
|
|---|
| 50 | dirs: string[];
|
|---|
| 51 | timeout: number;
|
|---|
| 52 | options: NodemonConfig;
|
|---|
| 53 | lastStarted: number;
|
|---|
| 54 | loaded: string[];
|
|---|
| 55 | load: (
|
|---|
| 56 | settings: NodemonSettings,
|
|---|
| 57 | ready: (config: NodemonEventConfig) => void,
|
|---|
| 58 | ) => void;
|
|---|
| 59 | reset: () => void;
|
|---|
| 60 | };
|
|---|
| 61 |
|
|---|
| 62 | export interface NodemonExecOptions {
|
|---|
| 63 | script: string;
|
|---|
| 64 | scriptPosition?: number;
|
|---|
| 65 | args?: string[];
|
|---|
| 66 | ext?: string; // "js,mjs" etc (should really support an array of strings, but I don't think it does right now)
|
|---|
| 67 | exec?: string; // node, python, etc
|
|---|
| 68 | execArgs?: string[]; // args passed to node, etc,
|
|---|
| 69 | nodeArgs?: string[]; // args passed to node, etc,
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | export interface NodemonConfig {
|
|---|
| 73 | /** restartable defaults to "rs" as a string the user enters */
|
|---|
| 74 | restartable?: false | string;
|
|---|
| 75 | colours?: boolean;
|
|---|
| 76 | execMap?: { [key: string]: string };
|
|---|
| 77 | ignoreRoot?: string[];
|
|---|
| 78 | watch?: string[];
|
|---|
| 79 | ignore?: string[];
|
|---|
| 80 | stdin?: boolean;
|
|---|
| 81 | runOnChangeOnly?: boolean;
|
|---|
| 82 | verbose?: boolean;
|
|---|
| 83 | signal?: string;
|
|---|
| 84 | stdout?: boolean;
|
|---|
| 85 | watchOptions?: WatchOptions;
|
|---|
| 86 | help?: string;
|
|---|
| 87 | version?: boolean;
|
|---|
| 88 | cwd?: string;
|
|---|
| 89 | dump?: boolean;
|
|---|
| 90 | delay?: number;
|
|---|
| 91 | monitor?: string[];
|
|---|
| 92 | spawn?: boolean;
|
|---|
| 93 | noUpdateNotifier?: boolean;
|
|---|
| 94 | legacyWatch?: boolean;
|
|---|
| 95 | pollingInterval?: number;
|
|---|
| 96 | /** @deprecated as this is "on" by default */
|
|---|
| 97 | js?: boolean;
|
|---|
| 98 | quiet?: boolean;
|
|---|
| 99 | configFile?: string;
|
|---|
| 100 | exitCrash?: boolean;
|
|---|
| 101 | execOptions?: NodemonExecOptions;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | export interface NodemonSettings extends NodemonConfig, NodemonExecOptions {
|
|---|
| 105 | events?: Record<string, string>;
|
|---|
| 106 | env?: Record<string, string>;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | export type Nodemon = {
|
|---|
| 110 | (settings: NodemonSettings): Nodemon;
|
|---|
| 111 | removeAllListeners(event: NodemonEventHandler): Nodemon;
|
|---|
| 112 | emit(type: NodemonEventHandler, event?: any): Nodemon;
|
|---|
| 113 | reset(callback: Function): Nodemon;
|
|---|
| 114 | restart(): Nodemon;
|
|---|
| 115 | config: NodemonSettings;
|
|---|
| 116 | } & NodemonEventListener & {
|
|---|
| 117 | [K in keyof NodemonEventListener as 'addListener']: NodemonEventListener[K];
|
|---|
| 118 | } & {
|
|---|
| 119 | [K in keyof NodemonEventListener as 'once']: NodemonEventListener[K];
|
|---|
| 120 | };
|
|---|
| 121 |
|
|---|
| 122 | declare const nodemon: Nodemon;
|
|---|
| 123 |
|
|---|
| 124 | export = nodemon;
|
|---|