settings-lib
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,3 +0,7 @@ | ||
# v0.2.0 / 2016-04-15 | ||
# v0.2.1 / 2016-04-19 | ||
* Fixed issue where environment config override file search was not properly working | ||
# v0.2.0 / 2016-04-18 | ||
* Introduced native `Promise` support | ||
@@ -4,0 +8,0 @@ * Moved to gulp for build tasks running |
@@ -345,8 +345,6 @@ var | ||
return new Promise((resolve, reject) => { | ||
let | ||
environmentOverridePath, | ||
searchEnvironment = | ||
process.env.NODE_ENV && | ||
settings.options.environmentSearchPaths && | ||
Array.isArray(settings.options.environmentSearchPaths); | ||
let searchEnvironment = | ||
process.env.NODE_ENV && | ||
settings.options.environmentSearchPaths && | ||
Array.isArray(settings.options.environmentSearchPaths); | ||
@@ -357,18 +355,28 @@ if (!searchEnvironment) { | ||
return Promise.race( | ||
return Promise.all( | ||
settings.options.environmentSearchPaths | ||
.reverse() // reversing paths so that the first found match is used | ||
.map((searchPath) => { | ||
environmentOverridePath = path.resolve([ | ||
let environmentOverridePath = path.resolve([ | ||
path.join(searchPath, process.env.NODE_ENV), | ||
'.json'].join('')); | ||
return checkIfFileExists(environmentOverridePath); | ||
return new Promise((resolve, reject) => { | ||
return checkIfFileExists(environmentOverridePath) | ||
.then((exists) => { | ||
return resolve({ | ||
path : environmentOverridePath, | ||
exists : exists | ||
}); | ||
}) | ||
.catch(reject); | ||
}); | ||
}) | ||
).then((exists) => { | ||
if (!exists) { | ||
).then((resultsList) => { | ||
let validPaths = resultsList.filter((result) => (result.exists)); | ||
if (!validPaths.length) { | ||
return resolve(); | ||
} | ||
return getConfigFileContents(environmentOverridePath) | ||
return getConfigFileContents(validPaths[0].path) | ||
.then((contents) => { | ||
@@ -380,3 +388,4 @@ settings.environmentConfig = contents; | ||
.catch(reject); | ||
}); | ||
}) | ||
.catch(reject); | ||
}); | ||
@@ -383,0 +392,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"main": "./lib/settings.js", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Joshua Thomas (http://github.com/brozeph)", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
38661
891