The OptionsManager is a babel inspired configuration system for plugin based apps. It is generic in the since it can be configured to use different namespaces. It handles command line args, env args, and file based configuration.
npm install @mrbuilder/optionsmanagerThe OptionsManager is a babel inspired configuration system for plugin based apps.
It is generic in the since it can be configured to use different namespaces.
It handles command line args, env args, and file based configuration.
It searches for a "plugins" or "presets" in a section named ${prefix} in
package.json or .${prefix}rc in addition it searches the ENV for${envPrefix}_PLUGINS, ${envPrefix}_PRESETS and after evaluation it search
${envPrefix}_INTERNAL_PRESETS
NODE_ENV if it is null. This tells the option managerNODE_ENV is conventionally used for test,development,production,production:server but the node env would``js static
const optionsManager = new OptionsManager({prefix:'whatever'});
`
* prefix - the prefix to use for internal ie.mrbuilder
* envPrefix - the environment prefix to use, defaults to prefix.toUpperCase();
* confPrefix - the prefix to configure things.
* rcFile - the rc file to use for preferences, uses .${prefix}rc as default.
* env - the environment default to process.env
* argv - the arguments array defaults to process.argv;
* cwd - A function returning current working dir defaults to process.cwd,
* info - A function for logging info level console.info || console.warn,
* debug - A function for logging debug level defaults console.info || console.warn,
* warn - A function for logging warn level console.warn,
* _require - A require function useful for scripts require,
* aliasObj - Alias's you want to pass
* handleNotFound - Function to call when a package is not found.
sh
export MRBUILDER_PLUGIN_EXAMPLE="{\"moreStuff\":1}"
`
Or to pass individual options, use __ to seperate plugin name and key names.`sh
export MRBUILDER_PLUGIN_EXAMPLE__MORE_STUFF="1";
``