Run opti-node in development with automatic restart.
The idea is to minimize how much system resources node uses and provide a lighter alternative to nodemon.
opti-node-watch -w dist -d 500 --script dist/index.js
opti-node-watch Watch these directories or files. (required, no default) -w dist/client --watch dist/server -w dist/shared -w dist/index.js --watch package.json --- Extensions: (optional, default: js,jsx,json) --ext js,jsx,ts,tsx,json Use of --ext is comma-separated without spaces. --- Reload delay in milliseconds: (optional) -d 1000 --delay 1000 --- Command to execute: (optional, default: opti-node) --exec node --exec python --- Which script to run: (required, no default) --script dist/index.js --- Debug, show which events happen: --debug --- Help: --help
Programmatic usage in JS
const path =const createWatcher =const distPath = pathconst indexPath = pathconst watcher =;watcher;watcher;// pipe to the processwatcherstdout;watcherstderr;watcher;watcherstart;
string, required, no default
number, optional, default
string, optional, default
["js", "jsx", "json"]
string, a command to execute
string, the node script
# create dev buildnpm run dev# create production buildnpm run prd
npm run prd before commit! Thanks
Differences from nodemon
I'm sure this has been done a million times now. There were certain aspects of nodemon which were inconvenient to my development process or it simply wouldn't work. I also wanted to see if I can run this with opti-node.
- Does not use chokidar
- No json file config e.g.
-eflag for extensions
- No ignore yet
- Less options for polling types
- No triggering other events
- Less ecosystem around it