feathers-configuration
Advanced tools
Comparing version 0.1.0 to 0.1.1
'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,2 +7,6 @@ value: true | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _fs = require('fs'); | ||
@@ -28,2 +30,3 @@ | ||
var configFolder = arguments.length <= 1 || arguments[1] === undefined ? 'config' : arguments[1]; | ||
var separator = arguments.length <= 2 || arguments[2] === undefined ? _path2.default.sep : arguments[2]; | ||
@@ -33,4 +36,26 @@ return function () { | ||
var env = app.settings.env; | ||
var config = require(_path2.default.join(root, configFolder, 'default.json')); | ||
var convert = function convert(current) { | ||
var result = {}; | ||
Object.keys(current).forEach(function (name) { | ||
var value = current[name]; | ||
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { | ||
value = convert(value); | ||
} else if (process.env[value]) { | ||
value = process.env[value]; | ||
} | ||
// Make relative paths absolute | ||
if (typeof value === 'string' && (value.indexOf('.') === 0 || value.indexOf('..') === 0)) { | ||
value = _path2.default.resolve(_path2.default.join(root, configFolder), value.replace(/\//g, separator)); | ||
} | ||
result[name] = value; | ||
}); | ||
return result; | ||
}; | ||
var config = convert(require(_path2.default.join(root, configFolder, 'default.json'))); | ||
debug('Initializing configuration for ' + env + ' environment'); | ||
@@ -52,11 +77,2 @@ | ||
if (process.env[value]) { | ||
value = process.env[value]; | ||
} | ||
// Make relative paths absolute | ||
if (typeof value === 'string' && (value.indexOf('.' + _path2.default.sep) === 0 || value.indexOf('..' + _path2.default.sep) === 0)) { | ||
value = _path2.default.resolve(_path2.default.join(root, configFolder), value); | ||
} | ||
debug('Setting ' + name + ' configuration value to', value); | ||
@@ -63,0 +79,0 @@ |
{ | ||
"name": "feathers-configuration", | ||
"description": "A small configuration module for your Feathers application.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/feathersjs/feathers-configuration", | ||
@@ -38,3 +38,3 @@ "main": "lib/", | ||
"mocha": "NODE_ENV=testing mocha test/ --compilers js:babel-core/register", | ||
"test": "npm run jshint && npm run mocha" | ||
"test": "npm run jshint && npm run mocha && nsp check" | ||
}, | ||
@@ -54,4 +54,5 @@ "directories": { | ||
"jshint": "^2.8.0", | ||
"mocha": "^2.3.3" | ||
"mocha": "^2.3.3", | ||
"nsp": "^2.2.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9939
79
8