1.0.1 • Published 8 years ago
envcnf v1.0.1
envcnf
const envcnf = require('envcnf');Functions
envcnf.env()- Returns your entire enviroment as an object. Same as node'sprocess.envobject. This function is here for mocking reasons.envcnf.get('MY_CONFIG_ENV_VAR')- Returns a string orundefined.envcnf.getMap('MY_CONFIG')- Returns an object containing all environment variables prefixed byMY_CONFIG_.envcnf.getList('MY_SERVERS')- Returns an array containing all enviroment variables prefixed byMY_SERVERS_followed by a positive integer number, sorted in numeric order.
Mocking your configuration
When using this module, you can mock your environment variables like this:
const td = require('testdouble');
td.replace(envcnf, 'env');
td.when(envcnf.env()).thenReturn({
'LANGUAGE': 'en_US:en',
'MY_ENV_VAR': 'some value',
'ETC': 'and so on...'
});
// Make your tests here...
td.reset();