Skip to content

Commit 47c98ec

Browse files
committedMay 28, 2024
feat(types): export types
feat(types): add default export
1 parent 287db41 commit 47c98ec

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed
 

‎TEMP_TEST_TS.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import nodemon from './index';
2+
3+
const test = nodemon({
4+
script: ''
5+
});

‎index.d.ts

+26-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type NodemonEventHandler =
1+
export type NodemonEventHandler =
22
| 'start'
33
| 'crash'
44
| 'exit'
@@ -10,7 +10,7 @@ type NodemonEventHandler =
1010
| 'stdout'
1111
| 'stderr';
1212

13-
type NodemonEventListener = {
13+
export type NodemonEventListener = {
1414
on(event: 'start' | 'crash' | 'readable', listener: () => void): Nodemon;
1515
on(event: 'log', listener: (e: NodemonEventLog) => void): Nodemon;
1616
on(event: 'stdout' | 'stderr', listener: (e: string) => void): Nodemon;
@@ -23,7 +23,7 @@ type NodemonEventListener = {
2323
): Nodemon;
2424
};
2525

26-
type Nodemon = {
26+
export type Nodemon = {
2727
(options?: NodemonSettings): Nodemon;
2828
on(event: 'start' | 'crash', listener: () => void): Nodemon;
2929
on(event: 'log', listener: (e: NodemonEventLog) => void): Nodemon;
@@ -72,10 +72,11 @@ type Nodemon = {
7272
emit(type: NodemonEventHandler, event?: any): Nodemon;
7373
reset(callback: Function): Nodemon;
7474
restart(): Nodemon;
75+
// TODO remy is that now only the config or does it also include the other stuff liek script?
7576
config: NodemonSettings;
7677
};
7778

78-
type NodemonEventLog = {
79+
export type NodemonEventLog = {
7980
/**
8081
detail*: what you get with nodemon --verbose.
8182
status: subprocess starting, restarting.
@@ -89,20 +90,20 @@ type NodemonEventLog = {
8990
colour: String;
9091
};
9192

92-
interface NodemonEventRestart {
93+
export interface NodemonEventRestart {
9394
matched?: {
9495
result: string[];
9596
total: number;
9697
};
9798
}
9899

99-
type NodemonEventQuit = 143 | 130;
100-
type NodemonEventExit = number;
100+
export type NodemonEventQuit = 143 | 130;
101+
export type NodemonEventExit = number;
101102

102103
// TODO: Define the type of NodemonEventConfig
103-
type NodemonEventConfig = any;
104+
export type NodemonEventConfig = any;
104105

105-
interface NodemonSettings {
106+
export interface NodemonConfig {
106107
/* restartable defaults to "rs" as a string the user enters */
107108
restartable?: false | String;
108109
colours?: Boolean;
@@ -117,10 +118,25 @@ interface NodemonSettings {
117118
watchOptions?: WatchOptions;
118119
}
119120

120-
interface WatchOptions {
121+
export interface NodemonSettings extends NodemonConfig {
122+
script: string;
123+
ext?: string; // "js,mjs" etc (should really support an array of strings, but I don't think it does right now)
124+
events?: { [key: string]: string };
125+
env?: { [key: string]: string };
126+
exec?: string; // node, python, etc
127+
execArgs?: string[]; // args passed to node, etc,
128+
129+
// TODO remy check if that is correct i have that in my code configured
130+
nodeArgs?: string[]; // args passed to node, etc,
131+
delay?: number;
132+
}
133+
134+
export interface WatchOptions {
121135
ignorePermissionErrors: boolean;
122136
ignored: string;
123137
persistent: boolean;
124138
usePolling: boolean;
125139
interval: number;
126140
}
141+
142+
export default function nodemon(settings: NodemonSettings): Nodemon;

0 commit comments

Comments
 (0)