config-watch
Simple configuration manager for node
Read and save a config from a JSON file and trigger an event when the file changes.
Installation
$ npm install --save config-watch
Usage
Create a new config with new Config(pathToJSON, options, callback)
:
const Config = ; let config = "config.json" defaults: foo: "bar" colors: tree: "green" sky: "blue" ;
callback(err, config)
is run once config is ready.
Get values:
let foo = config;let treeColor = config;
Set values:
config;config;
Watch for changes in config file:
config;
Check if a specific value has changed:
config;
Cancel the last change and get back to the previous config:
config; config;
Options
defaults
A JSON object which contains the default config.
watch
Set this to false
to disable watching the JSON file.
License
The MIT License (MIT) - Copyright (c) 2016 Thomas Brouard