@coast/dynamic-config
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -25,7 +25,10 @@ "use strict"; | ||
async loadConfig() { | ||
const dotEnvParse = dotenv_1.default.parse(fs_1.default.readFileSync(this.options.envFilePath)); | ||
const allKeys = this.getAllKeys(); | ||
const entries = {}; | ||
this.loadFromSource(allKeys, process.env, entries); | ||
this.loadFromSource(this.getAllUnsetKeys(allKeys, entries), dotEnvParse, entries); | ||
let dotEnvParse = {}; | ||
if (this.options.envFilePath !== undefined && fs_1.default.existsSync(this.options.envFilePath)) { | ||
dotEnvParse = dotenv_1.default.parse(fs_1.default.readFileSync(this.options.envFilePath)); | ||
this.loadFromSource(this.getAllUnsetKeys(allKeys, entries), dotEnvParse, entries); | ||
} | ||
const missingEntries = this.getAllUnsetKeys(allKeys, entries); | ||
@@ -32,0 +35,0 @@ if (missingEntries.length > 0) { |
@@ -7,3 +7,3 @@ /// <reference types="hapi__joi" /> | ||
* @property schema: Joi object schema that specifies all variables to load | ||
* @property envFilePath: Path to a dotenv file | ||
* @property envFilePath: Path to a dotenv file. Ignored if file is not found | ||
* @property ssmPaths: optional array of paths. Ex ['staging', 'core-api'] will lookup params at '/staging/core-api/.' | ||
@@ -15,5 +15,5 @@ * @property allowUnknownVariables: Allow variables not specified in the schema. | ||
schema: ObjectSchema; | ||
envFilePath: string; | ||
envFilePath?: string; | ||
ssmPaths?: string[]; | ||
allowUnknownVariables?: boolean; | ||
} |
{ | ||
"name": "@coast/dynamic-config", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
10975
146