yaconme v1.1.1
config-merger
The goal of this project is to provide a simple and lightweight way to merge a configuration with the environment variables or process arguments. In other words: With this you can override config entries based on environment and process.
Usage
const config = require('yaconme').config('config-prefix.')API
The api of config-merger exposes only one method, namely .config
config(prefix, options?): any
'prefix'
The prefix by which to distinguish between relevant variables/arguments. Every argument you want to use must be prefixed with this exact string followed by the path seperator ('.' for process arguments and '_' for environment variables by default).
examples
Environment variables
PREFIX_port=3000This will override the top level property 'port' with the value "3000"
options
Additional options like this:
export interface ConfigOptions {
  fallback?: any // your default configuration from which to start
  precedence?: Source[] // an order of precedence
  processArgs? // defaults to 'process.argv'
  processSeperator?: string // defaults to a '.'
  processEnv? // defaults to 'process.env',
  envSeperator?: string // defaults to a '_'
}
export enum Source {
  FALLBACK,
  ENVIRONMENT,
  PROCESS,
}Precedence
Precedence specifies which Source overwrites which.
There is a default order that overwrites a passed in config with 
the environment and the environment with the process arguments.
fallback <- environment <- process
However, you can specify any other order.
Nested objects/deep merging
It is possible to deeply overwrite values instead of a whole object like so
(given the prefix is config)
It is important to note the path seperators of process arguments can differ from those of environment variables!
my-app config.some.nested.value=overwritten config.some.other.path alsoOverwritten