vantage-watch
August 3, 2015 ยท View on GitHub
Listens for changes in Vantage.js extension files, and reloads the extensions without interrupting your app's lifecycle.
Useful when developing new Vantage commands.
Installation
npm install vantage-watch
npm install vantage
Usage
const Vantage = require('vantage');
const watch = require('vantage-watch');
const commands = require('./lib/vantage-commands');
let vantage = new Vantage();
vantage
.listen(4000)
.use(commands)
.use(watch, {
files: ['./lib/vantage-commands.js']
})
.show();
Now, whenever ./lib/vantage-commands.js is changed, Vantage will import and update its existing commands and / or register new commands.
Error Handling
If the watched file is not a valid Vantage extension, vantage-watch will gracefully catch the error and not attempt to load the module until it has been changed again, at which point it will retry. Examples of invalid imports include:
- Its
module.exportsdoes not return a function - It has syntax errors
- It is not a valid file
License
MIT