pelias-config
Advanced tools
Comparing version 4.12.0 to 4.12.1
@@ -77,11 +77,10 @@ const fs = require('fs'); | ||
* cloning an object with _.merge or _.assign | ||
* | ||
* see: https://lodash.com/docs/4.17.15#get | ||
*/ | ||
function addGetFunction(object) { | ||
const getFunction = function get(key) { | ||
return _.get(this, key); | ||
}; | ||
// set 'get' convenience function on returned object | ||
Object.defineProperty(object, 'get', { | ||
value: getFunction, | ||
value: _.get.bind(null, object), | ||
enumerable: false // allows comparison to `expected.json` in tests | ||
@@ -88,0 +87,0 @@ }); |
@@ -6,3 +6,3 @@ { | ||
"homepage": "https://github.com/pelias/config", | ||
"version": "4.12.0", | ||
"version": "4.12.1", | ||
"license": "MIT", | ||
@@ -9,0 +9,0 @@ "main": "index.js", |
var path = require('path'), | ||
config = require('../'), | ||
defaults = require('../config/defaults'); | ||
const path = require('path'); | ||
const config = require('../'); | ||
const defaults = require('../config/defaults'); | ||
const Joi = require('@hapi/joi'); | ||
@@ -274,2 +274,15 @@ | ||
test('get function supports defaultValue', (t) => { | ||
// set the PELIAS_CONFIG env var | ||
process.env.PELIAS_CONFIG = path.resolve(__dirname + '/../config/env.json'); | ||
const c = config.generate(); | ||
t.equals(c.get('foo', 'DEFAULT'), 'DEFAULT', 'default value used for keys that do not exist'); | ||
// unset the PELIAS_CONFIG env var | ||
delete process.env.PELIAS_CONFIG; | ||
t.end(); | ||
}); | ||
test('generateDefaults returns default config always', function(t) { | ||
@@ -276,0 +289,0 @@ // set the PELIAS_CONFIG env var, this config should NOT be used |
28063
700
33