Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@axah/env-utils

Package Overview
Dependencies
Maintainers
7
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axah/env-utils - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

7

lib/parse-env-variable/parse-boolean.js

@@ -25,7 +25,4 @@ "use strict";

default:
break;
} // $FlowFixMe
throw new Error(`Could not read the env-variable ${key}, because the value "${value}" cannot be parsed to a boolean.`);
return (0, _utils.throwErrorCannotBeParsed)(key, value);
}
}

@@ -20,4 +20,3 @@ "use strict";

if (Number.isNaN(date.getTime())) {
// $FlowFixMe
throw new Error(`Could not read the env-variable ${key}, because the value "${value}" cannot be parsed to a date.`);
return (0, _utils.throwErrorCannotBeParsed)(key, value);
}

@@ -24,0 +23,0 @@

@@ -20,4 +20,3 @@ "use strict";

if (!isFloat) {
// $FlowFixMe
throw new Error(`Could not read the env-variable ${key}, because the value "${value}" cannot be parsed to a float.`);
return (0, _utils.throwErrorCannotBeParsed)(key, value);
}

@@ -24,0 +23,0 @@

@@ -20,4 +20,3 @@ "use strict";

if (!isInteger) {
// $FlowFixMe
throw new Error(`Could not read the env-variable ${key}, because the value "${value}" cannot be parsed to an integer.`);
return (0, _utils.throwErrorCannotBeParsed)(key, value);
}

@@ -24,0 +23,0 @@

@@ -13,5 +13,9 @@ "use strict";

return (0, _utils.getDevValueOrThrowError)(key, valueInDev);
}
} // 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.
// But for smooth coding it should be as if the value cannot be undefined.
// eslint-disable-next-line flowtype/no-weak-types
return process.env[key];
}

@@ -6,21 +6,28 @@ "use strict";

});
exports.getDevValueOrThrowError = exports.isValueFilled = void 0;
exports.getDevValueOrThrowError = exports.throwErrorCannotBeParsed = exports.isValueFilled = void 0;
/**
* The key-value is normally always a string, but the code is written so it also works if not.
* Also empty strings are not allowed, openshift removes empty values in the yaml-file.
* Thus an empty string would behave differently locally and on openshift.
* Also empty strings are not allowed, openshift removes empty values in the yaml-file,
* thus an empty string would behave differently locally and on openshift.
*/
const isValueFilled = key => Object.prototype.hasOwnProperty.call(process.env, key) && process.env[key] !== null && process.env[key] !== undefined && process.env[key] !== '';
exports.isValueFilled = isValueFilled;
const throwErrorCannotBeParsed = (key, value) => {
// $FlowFixMe -> value can be undefined
throw new Error(`Could not read the env-variable ${key}, because the value "${value}" cannot be parsed.`);
};
/**
* Convenience function which returns the valueInDev, if the environment ist development (or test),
* otherwise an error is thrown (if not disabled).
* Convenience function which returns the valueInDev, if the environment ist development,
* otherwise an error is thrown.
*/
exports.isValueFilled = isValueFilled;
exports.throwErrorCannotBeParsed = throwErrorCannotBeParsed;
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 defined 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.');
}

@@ -30,4 +37,8 @@

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.
// But for smooth coding it should be as if the value cannot be undefined.
// eslint-disable-next-line flowtype/no-weak-types
return valueInDev;

@@ -34,0 +45,0 @@ };

{
"name": "@axah/env-utils",
"version": "1.1.1",
"version": "1.1.2",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc