super-config-file
v1.1.4
Published
Implements event driven live reloadable config, including a local override for git repos.
Readme
super-config-file
The idea of this package is to allow an application to live reload aspects/configs without restarting.
This will load a config and reload upon changes. It offers event listeners. It also will let you specify a default config to generate. The default config will merge new root elements which don't exist in the old config.
Installation
Use the package manager pip to install foobar.
const SuperConfigFile = require('super-config-file');
//import SuperConfigFile from 'super-config-file';
// Example - SuperConfigFile(SOURCE CONFIG, LOCAL OVERRIDE CONFIG (optional), default config useful for augmenting changes (optional)
const config1 = SuperConfigFile('example/config1.json', 'example/config1.local.json', {
"field": "value" // Default config (optional), will also update config with any new fields
});
config1.on('read', (config) => { // initial read + reload, useful to initialise/reinitialise objects
console.log('read');
console.log(config);
});
config1.on('reload', (config) => { // reload
console.log('reload');
console.log(config);
});
// Keep demo running to listen for changes
setInterval(() => {}, 500);