cnf

Configuration loader

Usage no npm install needed!

<script type="module">
  import cnf from 'https://cdn.skypack.dev/cnf';
</script>

README

cnf npm version Build Status Dependency Status devDependency Status

Configuration loader.

npm install -SE cnf 

To use it simply require it:

var config = require('cnf');

console.log('port: ' + config.http.port);

It will look for a configuration file called /config/$APP_ENV.js in the current working directory and will be extended with config from global.js.

To override configs use a command line argument prefixed with app.

node example.js --app.http.port 8080

The above line override http.port with 8080

To refer to another part of the config use

{
    port: 8080,
    siteUrl: "http://localhost:$(port)" //this will be "http://localhost:8080"
}

Add a regexp using

--app.mySetting "$regexp(/myRegExp/gmi)"