1 | # npmconf
|
2 |
|
3 | The config thing npm uses
|
4 |
|
5 | If you are interested in interacting with the config settings that npm
|
6 | uses, then use this module.
|
7 |
|
8 | However, if you are writing a new Node.js program, and want
|
9 | configuration functionality similar to what npm has, but for your
|
10 | own thing, then I'd recommend using [rc](https://github.com/dominictarr/rc),
|
11 | which is probably what you want.
|
12 |
|
13 | If I were to do it all over again, that's what I'd do for npm. But,
|
14 | alas, there are many systems depending on many of the particulars of
|
15 | npm's configuration setup, so it's not worth the cost of changing.
|
16 |
|
17 | ## USAGE
|
18 |
|
19 | ```javascript
|
20 | var npmconf = require('npmconf')
|
21 |
|
22 | // pass in the cli options that you read from the cli
|
23 | // or whatever top-level configs you want npm to use for now.
|
24 | npmconf.load({some:'configs'}, function (er, conf) {
|
25 | // do stuff with conf
|
26 | conf.get('some', 'cli') // 'configs'
|
27 | conf.get('username') // 'joebobwhatevers'
|
28 | conf.set('foo', 'bar', 'user')
|
29 | conf.save('user', function (er) {
|
30 | // foo = bar is now saved to ~/.npmrc or wherever
|
31 | })
|
32 | })
|
33 | ```
|