packagerc
Extended rc parser which extracts rc app name and defaults from package.json
USAGE
The API is the same as rc
, except the first argument -- the appname
string -- is also optional. If not provided, it will be extracted from the relevant package.json
, relative to process.cwd().
// package.json "name": "some-package" // ... "rc": "name": "somepackage"
The packagerc
lib allows you to invoke rc
with the appname
of "somepackage"
from anywhere within your app, optionally supplying defaults just like for rc
:
var conf = // user-specified defaults port: 2468confport === 2468
Config resolution is exactly the same as rc
:
// .somepackagerc "port": 8888 var conf = port: 2468confport === 8888
Defaults may also be provided within the package.json
, which will be overridden by any defaults you provide explicitly as part of the call to rc
.
// package.json "name": "some-package" // ... "rc": "name": "somepackage" "defaults": // package-specified defaults "port": 4444 "host": "0.0.0.0" var conf = confport === 4444confhost === '0.0.0.0' var conf = port: 2468confport === 2468confhost === '0.0.0.0'