nconf icon indicating copy to clipboard operation
nconf copied to clipboard

nconf should always be writable

Open gaspaio opened this issue 9 years ago • 8 comments

Why does the following code output 1 instead of 2 ? (nconf version = 0.7.1)

'use strict';

var conf = require('nconf');

conf.defaults({
    bingo: 1,
});

conf.set('bingo', 2);

console.log(conf.get('bingo'));

gaspaio avatar Mar 27 '15 09:03 gaspaio

It does work correctly if one specifies memory storage. I gess the set becomes sync in that case. Does it mean the set is async by default ? Is there any doc anywhere on this ?

'use strict';


var conf = require('nconf');

conf.use('memory');

conf.defaults({
    bingo: 1,
});

conf.set('bingo', 2);

console.log(conf.get('bingo'));

gaspaio avatar Mar 27 '15 13:03 gaspaio

var conf = require('nconf');

conf.set('foo', 1);

console.log(conf.get('foo')); // undefined

It seems really broken

monolithed avatar Apr 05 '15 13:04 monolithed

@indexzero, ping

monolithed avatar Apr 14 '15 00:04 monolithed

Will look into this soon.

indexzero avatar Apr 14 '15 15:04 indexzero

It is broken. None of the set examples in the readme work.

slawo avatar Jul 03 '15 08:07 slawo

@slawo a PR to the README would be welcomed with praise and admiration.

indexzero avatar Jul 03 '15 08:07 indexzero

The problem is due to no store has been defined when you call .set(). You must define it before, for instance: nconf.use('memory').

@indexzero could you consider using in-memory store by default avoiding the explicit store configuration?

h2non avatar Jul 09 '15 16:07 h2non

This will be the default behavior in 1.0.0

indexzero avatar Sep 20 '15 08:09 indexzero