settings-lib
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -50,3 +50,3 @@ "use strict"; | ||
function buildDefaultTypesMap(source, parentPath) { | ||
(0, _keys.default)(source).forEach(function (key) { | ||
(0, _keys["default"])(source).forEach(function (key) { | ||
var keyPath = parentPath ? [parentPath, key].join('.') : key; | ||
@@ -59,5 +59,5 @@ | ||
if ((0, _isArray.default)(source[key])) { | ||
if ((0, _isArray["default"])(source[key])) { | ||
defaultTypesMap[keyPath] = function (value) { | ||
if ((0, _isArray.default)(value)) { | ||
if ((0, _isArray["default"])(value)) { | ||
return value; | ||
@@ -83,3 +83,3 @@ } // remove front and back brackets, then split on commas | ||
if ((0, _typeof2.default)(source[key]) === 'object' && /^\[object\sObject\]$/.test(source[key].toString()) && source[key] !== null) { | ||
if ((0, _typeof2["default"])(source[key]) === 'object' && /^\[object\sObject\]$/.test(source[key].toString()) && source[key] !== null) { | ||
return buildDefaultTypesMap(source[key], keyPath); | ||
@@ -89,3 +89,3 @@ } | ||
defaultTypesMap[keyPath] = function (value) { | ||
switch ((0, _typeof2.default)(source[key])) { | ||
switch ((0, _typeof2["default"])(source[key])) { | ||
case 'boolean': | ||
@@ -114,4 +114,4 @@ return /^true|1$/i.test(value); | ||
function checkIfFileExists(filePath) { | ||
return new _promise.default(function (resolve) { | ||
return _fs.default.exists(filePath, resolve); | ||
return new _promise["default"](function (resolve) { | ||
return _fs["default"].exists(filePath, resolve); | ||
}); | ||
@@ -130,3 +130,3 @@ } | ||
function cloneAndMerge(objectList, stripEmptyObjects) { | ||
if (!(0, _isArray.default)(objectList)) { | ||
if (!(0, _isArray["default"])(objectList)) { | ||
return objectList; | ||
@@ -138,11 +138,11 @@ } | ||
cloner = function cloner(source, destination, prefix, ensureKey) { | ||
(0, _keys.default)(source).forEach(function (key) { | ||
(0, _keys["default"])(source).forEach(function (key) { | ||
var objectKeyPath = prefix ? [prefix, key].join('.') : key; | ||
if ((0, _isArray.default)(source[key])) { | ||
if ((0, _isArray["default"])(source[key])) { | ||
destination[key] = source[key]; | ||
} else if ((0, _typeof2.default)(source[key]) === 'object' && source[key] !== null) { | ||
} else if ((0, _typeof2["default"])(source[key]) === 'object' && source[key] !== null) { | ||
destination[key] = cloner(source[key], destination[key] || {}, objectKeyPath, ensureKey); // remove empty objects when applicable... | ||
if (!(0, _keys.default)(destination[key]).length && stripEmptyObjects) { | ||
if (!(0, _keys["default"])(destination[key]).length && stripEmptyObjects) { | ||
delete destination[key]; | ||
@@ -158,3 +158,3 @@ } | ||
objectList.forEach(function (item, i) { | ||
if ((0, _typeof2.default)(item) === 'object') { | ||
if ((0, _typeof2["default"])(item) === 'object') { | ||
cloned = cloner(item, cloned, '', i !== 0 && checkStrict); | ||
@@ -225,6 +225,6 @@ } | ||
function getConfigFileContents(filePath) { | ||
return new _promise.default(function (resolve, reject) { | ||
return new _promise["default"](function (resolve, reject) { | ||
var chunks = [], | ||
data, | ||
fileRead = _fs.default.createReadStream(filePath, { | ||
fileRead = _fs["default"].createReadStream(filePath, { | ||
encoding: 'utf8' | ||
@@ -239,5 +239,5 @@ }); | ||
if (RE_YAML.test(_path.default.extname(filePath))) { | ||
if (RE_YAML.test(_path["default"].extname(filePath))) { | ||
try { | ||
data = _yaml.default.parse(content, { | ||
data = _yaml["default"].parse(content, { | ||
merge: true | ||
@@ -278,3 +278,3 @@ }); | ||
function loadBaseConfig() { | ||
return new _promise.default(function (resolve, reject) { | ||
return new _promise["default"](function (resolve, reject) { | ||
if (!settings.options.baseSettingsPath) { | ||
@@ -289,3 +289,3 @@ settings.baseConfig = {}; | ||
return resolve(); | ||
}).catch(reject); | ||
})["catch"](reject); | ||
}); | ||
@@ -301,3 +301,3 @@ } | ||
function loadCommandLineConfig() { | ||
return new _promise.default(function (resolve, reject) { | ||
return new _promise["default"](function (resolve, reject) { | ||
var args = process.argv.slice(DEFAULT_ARGV_START_POSITION), | ||
@@ -307,3 +307,3 @@ // removes node command | ||
if (!(0, _isArray.default)(settings.options.commandLineSwitches) || settings.options.commandLineSwitches.length < 1) { | ||
if (!(0, _isArray["default"])(settings.options.commandLineSwitches) || settings.options.commandLineSwitches.length < 1) { | ||
return resolve(); | ||
@@ -334,3 +334,3 @@ } // iterate args from command line | ||
return resolve(); | ||
}).catch(reject); | ||
})["catch"](reject); | ||
}); | ||
@@ -346,6 +346,6 @@ } | ||
function loadCommandLineSwitches() { | ||
return new _promise.default(function (resolve) { | ||
return new _promise["default"](function (resolve) { | ||
var args = process.argv.slice(DEFAULT_ARGV_START_POSITION), | ||
// removes node command | ||
commandLineMapKeys = (0, _keys.default)(settings.options.readCommandLineMap), | ||
commandLineMapKeys = (0, _keys["default"])(settings.options.readCommandLineMap), | ||
commandLineSettings = []; // return if there are no configured command line mappings to look for | ||
@@ -380,4 +380,4 @@ | ||
function loadEnvironmentConfig() { | ||
return new _promise.default(function (resolve, reject) { | ||
var searchEnvironment = process.env.NODE_ENV && settings.options.environmentSearchPaths && (0, _isArray.default)(settings.options.environmentSearchPaths); | ||
return new _promise["default"](function (resolve, reject) { | ||
var searchEnvironment = process.env.NODE_ENV && settings.options.environmentSearchPaths && (0, _isArray["default"])(settings.options.environmentSearchPaths); | ||
@@ -388,7 +388,7 @@ if (!searchEnvironment) { | ||
return _promise.default.all(settings.options.environmentSearchPaths // check for .json files... | ||
return _promise["default"].all(settings.options.environmentSearchPaths // check for .json files... | ||
.map(function (searchPath) { | ||
var environmentOverridePath = _path.default.resolve([_path.default.join(searchPath, process.env.NODE_ENV), '.json'].join('')); | ||
var environmentOverridePath = _path["default"].resolve([_path["default"].join(searchPath, process.env.NODE_ENV), '.json'].join('')); | ||
return new _promise.default(function (resolve, reject) { | ||
return new _promise["default"](function (resolve, reject) { | ||
return checkIfFileExists(environmentOverridePath).then(function (exists) { | ||
@@ -399,9 +399,9 @@ return resolve({ | ||
}); | ||
}).catch(reject); | ||
})["catch"](reject); | ||
}); | ||
}).concat(settings.options.environmentSearchPaths // check for .yml files... | ||
.map(function (searchPath) { | ||
var environmentOverridePath = _path.default.resolve([_path.default.join(searchPath, process.env.NODE_ENV), '.yml'].join('')); | ||
var environmentOverridePath = _path["default"].resolve([_path["default"].join(searchPath, process.env.NODE_ENV), '.yml'].join('')); | ||
return new _promise.default(function (resolve, reject) { | ||
return new _promise["default"](function (resolve, reject) { | ||
return checkIfFileExists(environmentOverridePath).then(function (exists) { | ||
@@ -412,3 +412,3 @@ return resolve({ | ||
}); | ||
}).catch(reject); | ||
})["catch"](reject); | ||
}); | ||
@@ -427,4 +427,4 @@ }))).then(function (resultsList) { | ||
return resolve(); | ||
}).catch(reject); | ||
}).catch(reject); | ||
})["catch"](reject); | ||
})["catch"](reject); | ||
}); | ||
@@ -440,5 +440,5 @@ } | ||
function loadEnvironmentVariables() { | ||
return new _promise.default(function (resolve) { | ||
return new _promise["default"](function (resolve) { | ||
var environmentKeys, | ||
environmentMapKeys = (0, _keys.default)(settings.options.readEnvironmentMap), | ||
environmentMapKeys = (0, _keys["default"])(settings.options.readEnvironmentMap), | ||
environmentSettings = []; // return if there are no configured command line mappings to look for | ||
@@ -450,3 +450,3 @@ | ||
environmentKeys = (0, _keys.default)(process.env); | ||
environmentKeys = (0, _keys["default"])(process.env); | ||
environmentKeys.forEach(function (key) { | ||
@@ -471,10 +471,6 @@ if (environmentMapKeys.indexOf(key) >= 0) { | ||
settings.initialize = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee2(options, callback) { | ||
settings.initialize = /*#__PURE__*/function () { | ||
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(options, callback) { | ||
var exec; | ||
return _regenerator.default.wrap(function _callee2$(_context2) { | ||
return _regenerator["default"].wrap(function _callee2$(_context2) { | ||
while (1) { | ||
@@ -496,9 +492,5 @@ switch (_context2.prev = _context2.next) { | ||
exec = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref2 = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee() { | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
exec = /*#__PURE__*/function () { | ||
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() { | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
@@ -543,3 +535,3 @@ switch (_context.prev = _context.next) { | ||
} | ||
}, _callee, this); | ||
}, _callee); | ||
})); | ||
@@ -567,3 +559,3 @@ | ||
return callback(null, result); | ||
}).catch(function (ex) { | ||
})["catch"](function (ex) { | ||
return callback(ex); | ||
@@ -577,3 +569,3 @@ })); | ||
} | ||
}, _callee2, this); | ||
}, _callee2); | ||
})); | ||
@@ -580,0 +572,0 @@ |
@@ -0,1 +1,6 @@ | ||
# v1.1.2 / 2020-03-13 | ||
* Updated dependencies | ||
* Updated Node versions in Travis configuration | ||
# v1.1.1 / 2019-02-11 | ||
@@ -2,0 +7,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"main": "./dist/settings.js", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"author": "Joshua Thomas (http://github.com/brozeph)", | ||
@@ -23,25 +23,2 @@ "license": "MIT", | ||
"homepage": "http://github.com/brozeph/settings-lib", | ||
"dependencies": { | ||
"@babel/runtime-corejs2": "^7.3.1", | ||
"yaml": "^1.2.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/plugin-transform-runtime": "^7.2.0", | ||
"@babel/preset-env": "^7.2.3", | ||
"@babel/register": "^7.0.0", | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-plugin-istanbul": "^5.1.0", | ||
"chai": "^4.2.0", | ||
"coveralls": "^3.0.2", | ||
"eslint-plugin-babel": "^5.3.0", | ||
"gulp": "^4.0.0", | ||
"gulp-babel": "^8.0.0", | ||
"gulp-clean": "^0.4.0", | ||
"gulp-eslint": "^5.0.0", | ||
"gulp-sourcemaps": "^2.6.4", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0" | ||
}, | ||
"scripts": { | ||
@@ -71,3 +48,26 @@ "lint": "gulp lint", | ||
"sourceMap": false | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.8.4", | ||
"@babel/core": "^7.8.7", | ||
"@babel/plugin-transform-runtime": "^7.8.3", | ||
"@babel/preset-env": "^7.8.7", | ||
"@babel/register": "^7.8.6", | ||
"babel-eslint": "^10.1.0", | ||
"babel-plugin-istanbul": "^6.0.0", | ||
"chai": "^4.2.0", | ||
"coveralls": "^3.0.9", | ||
"eslint-plugin-babel": "^5.3.0", | ||
"gulp": "^4.0.2", | ||
"gulp-babel": "^8.0.0", | ||
"gulp-clean": "^0.4.0", | ||
"gulp-eslint": "^6.0.0", | ||
"gulp-sourcemaps": "^2.6.5", | ||
"mocha": "^7.1.0", | ||
"nyc": "^15.0.0" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime-corejs2": "^7.8.7", | ||
"yaml": "^1.8.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
62781
443
Updatedyaml@^1.8.2