node-reload
For node.js to reload the module ,which was to be load by require
, automaticly.
Install
npm install auto-reload
Example
Reload Json
test/data/json.json
test/json.js
const fs = ;const reload = ;const data = ; // reload after file changed // print data every sec; // update data.json after startup;
Result:
0 'Alan'0 'Alan'0 'Alan'0 'Alan'041179045320583496 'Test'
Reload Js file
Realod function haven't support
test/data/code.js
moduleexports = num: 0 str: 'string' obj: name: 'Alan' age: 18 list: 13579;
test/code.js
const reload = ;const data = ; // print data from module every sec; // If you update the `time` in test/data/code.js// the output will change immediately
Aims
- auto reload json file
- auto reload js file
- fix memory leak
- provide more options (include logger etc.)
- rewrite with promise (include improve exception catch)
- add tests with ava