File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ node-dev src/server.ts
3232There are a couple of command-line options that can be used to control which files are watched and what happens when they change:
3333
3434- ` --clear ` - Clear the screen on restart
35+ - ` --debounce ` - Debounce change events by time in milliseconds (non-polling mode, default: 10)
3536- ` --dedupe ` - [ Dedupe dynamically] ( https://www.npmjs.org/package/dynamic-dedupe )
3637- ` --deps ` :
3738 - ` -1 ` - Watch the whole dependency tree
@@ -41,6 +42,7 @@ There are a couple of command-line options that can be used to control which fil
4142- ` --fork ` - Hook into child_process.fork
4243- ` --graceful_ipc <msg> ` - Send 'msg' as an IPC message instead of SIGTERM for restart/shutdown
4344- ` --ignore ` - A file whose changes should not cause a restart
45+ - ` --interval ` - Polling interval in milliseconds (default: 1000)
4446- ` --notify=false ` - Disable desktop notifications
4547- ` --poll ` - Force polling for file changes (Caution! CPU-heavy!)
4648- ` --respawn ` - Keep watching for changes after the script has exited
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const resolveMain = require('./resolve-main');
55
66const defaultConfig = {
77 clear : false ,
8+ debounce : 10 ,
89 dedupe : false ,
910 deps : 1 ,
1011 extensions : {
@@ -15,6 +16,7 @@ const defaultConfig = {
1516 fork : true ,
1617 graceful_ipc : '' ,
1718 ignore : [ ] ,
19+ interval : 1000 ,
1820 notify : true ,
1921 poll : false ,
2022 respawn : false ,
Original file line number Diff line number Diff line change @@ -17,10 +17,12 @@ module.exports = function (
1717 nodeArgs ,
1818 {
1919 clear,
20+ debounce,
2021 dedupe,
2122 deps,
2223 graceful_ipc : gracefulIPC ,
2324 ignore,
25+ interval,
2426 notify : notifyEnabled ,
2527 poll : forcePolling ,
2628 respawn,
@@ -57,7 +59,7 @@ module.exports = function (
5759 // Run ./dedupe.js as preload script
5860 if ( dedupe ) process . env . NODE_DEV_PRELOAD = localPath ( 'dedupe' ) ;
5961
60- const watcher = filewatcher ( { forcePolling } ) ;
62+ const watcher = filewatcher ( { debounce , forcePolling, interval } ) ;
6163 let isPaused = false ;
6264
6365 // The child_process
Original file line number Diff line number Diff line change @@ -103,3 +103,39 @@ tap.test('--clear enables clear', t => {
103103 t . true ( clear ) ;
104104 t . done ( ) ;
105105} ) ;
106+
107+ tap . test ( 'interval default' , t => {
108+ const {
109+ opts : { interval }
110+ } = cli ( [ 'node' , 'bin/node-dev' , 'test' ] ) ;
111+
112+ t . is ( interval , 1000 ) ;
113+ t . done ( ) ;
114+ } ) ;
115+
116+ tap . test ( '--interval=2000' , t => {
117+ const {
118+ opts : { interval }
119+ } = cli ( [ 'node' , 'bin/node-dev' , '--interval=2000' , 'test' ] ) ;
120+
121+ t . is ( interval , 2000 ) ;
122+ t . done ( ) ;
123+ } ) ;
124+
125+ tap . test ( 'debounce default' , t => {
126+ const {
127+ opts : { debounce }
128+ } = cli ( [ 'node' , 'bin/node-dev' , 'test' ] ) ;
129+
130+ t . is ( debounce , 10 ) ;
131+ t . done ( ) ;
132+ } ) ;
133+
134+ tap . test ( '--debounce=2000' , t => {
135+ const {
136+ opts : { debounce }
137+ } = cli ( [ 'node' , 'bin/node-dev' , '--debounce=2000' , 'test' ] ) ;
138+
139+ t . is ( debounce , 2000 ) ;
140+ t . done ( ) ;
141+ } ) ;
You can’t perform that action at this time.
0 commit comments