Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Config.prototype.get = function(propertyName, defaultValue, sep) {
have(arguments, {propertyName: 'str', sep: 'opt str'});
debug('config.get of '+propertyName+', def='+defaultValue+', sep='+sep);
assert.ok(is.nonEmptyStr(propertyName));
if (!is.nonEmptyStr(sep)) sep = defaultSepChr;
if (!is.nonEmptyString(propertyName))
return defaultValue || null;
// Try to get value from environemnt first
// We convert name to upper case and if '.' is used as a sep char,
// replace with "_", so 'logging.name' becomes "LOGGING_NAME"
var envPropName;
if (sep === '.')
envPropName = propertyName.replace(/\./g, '_');
else
envPropName = propertyName.replace(new RegExp(sep, 'g'), '_');
if (!is.nonEmptyStr(envPropName)) {
debug('Could not remove "."s from '+ propertyName);
} else {
envPropName = envPropName.toUpperCase();
}