jsconfig
loading configs from javascript files with default configs and cli support
installation
npm install jsconfig
usage
jsconfig can load config file formats whatever node.js can require:
- by default it's always possible to load
*.js
files - if you want to use coffee-script config files, just do a require('coffee-script') before and you're able to require
*.coffee
files as well - since node.js 0.5.x it's even possible to require
.*json
files - if you're hardcore you can write your config in cpp and compile them to
*.node
files
var config = ;config; // in another fileconfig = ; // this is filled after config.load call
a normal config file structures looks like this:
moduleexports = {};
config.load
config;console;// orconfig;
load all config files and fills config with all settings.
required
config.defaults
config;
load some default config files.
config.set
config; // default is false
ignore all nonexisting config files and options.
does not apply on default config files.
config; // similar to config.user.name = process.env.USER
define all environment variables, that should be included into config.
this overwrites config file values (default config files too).
config.cli
config; // results only in config.user.name = opts.user (after config.load call)
this sets up the command line interface. its basicly node-cli with on little change: if cli result should be saved in config, the cli-array should be packed into a second (outer) array as second element (the first is the position in the config object).
config.merge
config;// orconfig;
deep copy new values into config.