Auto-restart node apps! (simpler alternative to the original nodemon)
npm install thann/nodemon
if (require('nodemon')()) return;
And your app will restart on any changes to the folder it's in!
This is just a wrapper for chokidar.watch(...)
,
so you can pass any of those options.
You can also run arbitrary commands in the terminal like this:
$ nodemon echo cool
const watcher = require('nodemon')(
__dirname, // folder to watch
{ // chokidar options
ignored: /.*\/node_modules\/.*/
},
{ // library options
killSignal: 'SIGTERM'
}
);
if (watcher) {
watcher.on('change', f => console.log('----- changed:', f));
return;
}
See test.js for an example app.