acm
v2.0.1
Published
another configuraiton module
Downloads
28
Readme
acm - another configuration module
is a configuration reader. it can retrieve
values from command line arguments, environment variables, and local files of
different formats.
usage
just require
ing acm
will return an instantiated Configuration object that
uses some pretty standard defaults. this is a function you can use
to get your configuration. the funciton object will also have a .set
method
you can use to update values (in memory) and a .ref
property which is the
actual Configuration
instance. running config('github.username')
will
result in the following checks:
- a
--github.username
command line argument will be checked - a
GITHUB_USERNAME
environment variable will be checked - a file named
github.{json,json5,yaml,yml,ini}
will be checked and parsed for the value
defaults
acm
will make sensible decisions about where to check for configuration. for
example, when checking for:
- arguments: defaults to
process.argv
- environment variables: defaults to
process.env
- files: defaults to
$PWD/config/
then$PWD
file extension and parsers
available extensions are: .ini
, .json
/.json5
, and .yaml
/.yml
.
parsers for each of these extensions are located in acm.prototype.parsers
.
adding new properties to this object will add support for addition file
extension. property values should be functions that take a string, parse it,
and return an object.
file merge fields
files can use merge fields. lodash's
template function is used to merge data into
string, and acm.prototype.fields
is passed as the data
argument. by default
.fields
comes with a reference to process
and process.env
(labeled as
env
)