@dynrl/drl-settings
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -5,2 +5,3 @@ "use strict"; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
/** | ||
@@ -36,2 +37,3 @@ * Wrapper for accessing settings in DRL apps and modules. | ||
if (this.useEnvFile() && filePath) { | ||
filePath = path.resolve(filePath); | ||
if (!fs.existsSync(filePath)) { | ||
@@ -65,10 +67,9 @@ throw new Error(`Could not locate .env file at ${filePath}`); | ||
static getSetting(key) { | ||
const val = process.env[key]; | ||
// Check validity of key | ||
if (typeof val === 'undefined' || val === null) { | ||
throw new Error(`Could not locate required setting, ${key}. Add this to your settings.json`); | ||
} | ||
if (!this.WhiteList[key]) { | ||
throw new Error(`Non-sanctioned key detected, ${key}. Make sure keys are registered during the initSettings call.`); | ||
} | ||
const val = process.env[key]; | ||
if (val == null) { | ||
throw new Error(`Could not locate required setting, ${key}. Add this to your environment variables.`); | ||
} | ||
if (val === '') { | ||
@@ -75,0 +76,0 @@ this.warn(`Empty key detected, ${key}.`); |
{ | ||
"name": "@dynrl/drl-settings", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Standardizes settings access", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
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
7886
4
125