confenv
Installation
$ npm i [-g] [--save] confenv[@tag]
Before you can start
const confenv = ;
The confenv
module itself already returns a ready to use instance of the ConfEnv
constructor so it's not necessary
to create a new one. If you want to create a new instance anyway just go ahead and use the confenv.$new()
function like below:
const confenv = ;
Options
There are several ways to define you own (runtime) options for the confenv
module. If no custom options are defined
the module will always fallback to the default values defined by confenv.DEFAULT_RC
. Otherwise it will try to
parse an existing root configuration file named .confrc
that will override the default values. At least the options
passed in to the constructor will be used to again override the used values.
DEFAULT_RC
Runtime
confenv
internally generates reasonable reusable values along a configuration that's returned by the confenv.get()
function. Those values are prefixed with a $
sign and can be directly accessed via the returned object
. Let's say
we got an existing configuration object
instance named config
so the following fields would be accessible:
/*** @returns */config$path; /*** @returns */config$term;
Note
These fields are not going to be displayed by a JSON.stringify()
call since they're create by the Object.defineProperty()
function using the default descriptor values apart from writable
that's set to true
.
For more information please have a look at the developer API.
API
Static functions
/** * Reads and parses a potentially existing configuration file for the * the function will return the default RC options defined by * @returns The configuration JSON data as object instance */confenv;
Prototype functions
/** * Exposes all configuration files the * will fallback to the pattern defined for the default token * @param * @returns */confenv; /** * Returns the env value for the defined environment variable key * @param * @returns */confenv; /** * Receives a configuration * match expression to search for the desired file * @param * @returns */confenv;