1 | var fs = require('fs'),
|
2 | path = require('path'),
|
3 | nconf = require('./lib/nconf');
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | var single = new nconf.Provider({
|
11 | env: true,
|
12 | argv: true,
|
13 | store: {
|
14 | type: 'file',
|
15 | file: path.join(__dirname, 'config.json')
|
16 | }
|
17 | });
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var multiple = new nconf.Provider({
|
24 | stores: [
|
25 | { name: 'user', type: 'file', file: path.join(__dirname, 'user-config.json') },
|
26 | { name: 'global', type: 'global', file: path.join(__dirname, 'global-config.json') }
|
27 | ]
|
28 | });
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | nconf.use('file', { file: path.join(__dirname, 'config.json') });
|
34 | nconf.set('database:host', '127.0.0.1');
|
35 | nconf.set('database:port', 5984);
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | var database = nconf.get('database');
|
41 | console.dir(database);
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | nconf.save(function (err) {
|
47 | fs.readFile(path.join(__dirname, 'config.json'), function (err, data) {
|
48 | console.dir(JSON.parse(data.toString()))
|
49 | });
|
50 | }); |
\ | No newline at end of file |