@axah/env-utils
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -12,3 +12,3 @@ "use strict"; | ||
if (!(0, _utils.isValueFilled)(key)) { | ||
return (0, _utils.getDevValueOrThrowError)(key, valueInDev); | ||
return (0, _utils.getDevValueIfNotProduction)(key, valueInDev); | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (!(0, _utils.isValueFilled)(key)) { | ||
return (0, _utils.getDevValueOrThrowError)(key, valueInDev); | ||
return (0, _utils.getDevValueIfNotProduction)(key, valueInDev); | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (!(0, _utils.isValueFilled)(key)) { | ||
return (0, _utils.getDevValueOrThrowError)(key, valueInDev); | ||
return (0, _utils.getDevValueIfNotProduction)(key, valueInDev); | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (!(0, _utils.isValueFilled)(key)) { | ||
return (0, _utils.getDevValueOrThrowError)(key, valueInDev); | ||
return (0, _utils.getDevValueIfNotProduction)(key, valueInDev); | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (!(0, _utils.isValueFilled)(key)) { | ||
return (0, _utils.getDevValueOrThrowError)(key, valueInDev); | ||
return (0, _utils.getDevValueIfNotProduction)(key, valueInDev); | ||
} // In dev environment it can be, that the developer decides not to set a value, | ||
@@ -15,0 +15,0 @@ // because he knows locally it won't be use - e.g. CERT variables. |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.getDevValueOrThrowError = exports.throwErrorCannotBeParsed = exports.isValueFilled = void 0; | ||
exports.getDevValueIfNotProduction = exports.throwErrorCannotBeParsed = exports.isValueFilled = void 0; | ||
@@ -23,4 +23,4 @@ /** | ||
/** | ||
* Convenience function which returns the valueInDev, if the environment ist development, | ||
* otherwise an error is thrown. | ||
* Convenience function which returns the valueInDev, | ||
* if the environment isn't production, otherwise an error is thrown. | ||
*/ | ||
@@ -31,11 +31,7 @@ | ||
const getDevValueOrThrowError = (key, valueInDev) => { | ||
if (!process.env.NODE_ENV) { | ||
throw new Error('The environment variable NODE_ENV is not set. The package @axah/env-utils only works with a NODE_ENV set to a value.'); | ||
} | ||
if (process.env.NODE_ENV !== 'development') { | ||
const getDevValueIfNotProduction = (key, valueInDev) => { | ||
if (process.env.NODE_ENV === 'production') { | ||
throw new Error(`The environment variable ${key} has not been defined or is empty.`); | ||
} // In dev environment it can be, that the developer decides not to set a value, | ||
// because he knows locally it won't be use - e.g. CERT variables. | ||
// because he knows locally it won't be used - e.g. CERT variables. | ||
// But for smooth coding it should be as if the value cannot be undefined. | ||
@@ -48,2 +44,2 @@ // eslint-disable-next-line flowtype/no-weak-types | ||
exports.getDevValueOrThrowError = getDevValueOrThrowError; | ||
exports.getDevValueIfNotProduction = getDevValueIfNotProduction; |
{ | ||
"name": "@axah/env-utils", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"main": "lib/main.js", | ||
@@ -5,0 +5,0 @@ "license": "UNLICENSED", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
12594
150