UNPKG

1.05 kBMarkdownView Raw
1# npmconf
2
3The config thing npm uses
4
5If you are interested in interacting with the config settings that npm
6uses, then use this module.
7
8However, if you are writing a new Node.js program, and want
9configuration functionality similar to what npm has, but for your
10own thing, then I'd recommend using [rc](https://github.com/dominictarr/rc),
11which is probably what you want.
12
13If I were to do it all over again, that's what I'd do for npm. But,
14alas, there are many systems depending on many of the particulars of
15npm's configuration setup, so it's not worth the cost of changing.
16
17## USAGE
18
19```javascript
20var 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.
24npmconf.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```