mconfig

2.2.1 • Public • Published

MConfig Build Status

Simple to read config file for modules. Support mulit cwd.

Installation

$ npm install mconfig

Usage

$ mkdir config
$ vi config/.log.conf.js

module.exports = {
    LOG_PATH: '/log/error/',
    LOG_PATH2: '/log/warn/'
}


$ vi config/my.defaults.conf.js

module.exports = {
    "LOG_PATH3": "/log/nolog/"
}

Read config file by MConfig

var mconfig = require('mconfig');
var config = mconfig('.log.conf.js');
console.log(config('LOG_PATH')); // print '/log/error/'
 
console.log(mconfig('.log.conf.js', 'LOG_PATH2')); // print '/log/warn/'
 
console.log(mconfig.defaults('LOG_PATH3')); // print '/log/nolog/'

Notice

MConfig reads configuration files in the ./config directory for the running process.

This can be overridden by running application width mconfig_cwd argv or setting the $NODE_CONFIG_DIR environment variable.

node app.js --mconfig_cwd=/home/user/etc/node_config/

Of course, you can also set mconfig module cwd variable to change the directory.

Difference from config

This is similar to config but adds features.

Multiple profiles helps to reduce the inter-dependence. This is useful for function profile.

Readme

Keywords

Package Sidebar

Install

npm i mconfig

Weekly Downloads

2

Version

2.2.1

License

MIT

Last publish

Collaborators

  • bacra