env-vars-validator
Advanced tools
Comparing version 1.1.6 to 1.1.7
@@ -28,3 +28,2 @@ 'use strict'; | ||
var _ref, _ref$toString, _ref$toString$toLower; | ||
var ajv = /*#__PURE__*/new Ajv({ | ||
@@ -77,8 +76,20 @@ coerceTypes: true, | ||
var currentEnv = (_ref = "development" ) == null ? void 0 : (_ref$toString = /*#__PURE__*/_ref.toString()) == null ? void 0 : (_ref$toString$toLower = /*#__PURE__*/_ref$toString.toLowerCase()) == null ? void 0 : /*#__PURE__*/_ref$toString$toLower.trim(); | ||
var isProductionEnv = currentEnv === Environment.PRODUCTION; | ||
var isDevelopmentEnv = currentEnv === Environment.DEVELOPMENT; | ||
var isTestEnv = currentEnv === Environment.TEST; | ||
var isDeployedEnv = currentEnv !== Environment.DEVELOPMENT && currentEnv !== Environment.TEST; | ||
var currentEnv = function currentEnv() { | ||
var _ref, _ref$toString, _ref$toString$toLower; | ||
return (_ref = "development" ) == null ? void 0 : (_ref$toString = _ref.toString()) == null ? void 0 : (_ref$toString$toLower = _ref$toString.toLowerCase()) == null ? void 0 : _ref$toString$toLower.trim(); | ||
}; | ||
var isProductionEnv = function isProductionEnv() { | ||
return currentEnv() === Environment.PRODUCTION; | ||
}; | ||
var isDevelopmentEnv = function isDevelopmentEnv() { | ||
return currentEnv() === Environment.DEVELOPMENT; | ||
}; | ||
var isTestEnv = function isTestEnv() { | ||
return currentEnv() === Environment.TEST; | ||
}; | ||
var isDeployedEnv = function isDeployedEnv() { | ||
return currentEnv() !== Environment.DEVELOPMENT && currentEnv() !== Environment.TEST; | ||
}; | ||
exports.currentEnv = currentEnv; | ||
@@ -85,0 +96,0 @@ exports.isDeployedEnv = isDeployedEnv; |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r,o,t=e(require("ajv")),n=e(require("ajv-formats"));function s(){return(s=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e}).apply(this,arguments)}var i,a=new t({coerceTypes:!0,useDefaults:!0});n(a),function(e){e.PRODUCTION="production",e.DEVELOPMENT="development",e.TEST="test"}(i||(i={}));var p=null==(r="production".toString())||null==(o=r.toLowerCase())?void 0:o.trim(),v=p===i.PRODUCTION,c=p===i.DEVELOPMENT,u=p===i.TEST,l=p!==i.DEVELOPMENT&&p!==i.TEST;exports.currentEnv=p,exports.isDeployedEnv=l,exports.isDevelopmentEnv=c,exports.isProductionEnv=v,exports.isTestEnv=u,exports.validateEnv=function(e,r){void 0===r&&(r={coerceVars:!0});var o=r.requiredProperties,t=r.coerceVars;if(!e)throw new Error("Impossible to load environment variables validation schema.");var n={type:"object",properties:s({},e),required:o},i=a.compile(n),p=s({},process.env);if(!i(p))throw new Error(a.errorsText(i.errors,{dataVar:"process.env"}));(void 0===t||t)&&(process.env=p)}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("ajv")),t=e(require("ajv-formats"));function o(){return(o=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}var n,i=new r({coerceTypes:!0,useDefaults:!0});t(i),function(e){e.PRODUCTION="production",e.DEVELOPMENT="development",e.TEST="test"}(n||(n={}));var s=function(){var e,r;return null==(e="production".toString())||null==(r=e.toLowerCase())?void 0:r.trim()};exports.currentEnv=s,exports.isDeployedEnv=function(){return s()!==n.DEVELOPMENT&&s()!==n.TEST},exports.isDevelopmentEnv=function(){return s()===n.DEVELOPMENT},exports.isProductionEnv=function(){return s()===n.PRODUCTION},exports.isTestEnv=function(){return s()===n.TEST},exports.validateEnv=function(e,r){void 0===r&&(r={coerceVars:!0});var t=r.requiredProperties,n=r.coerceVars;if(!e)throw new Error("Impossible to load environment variables validation schema.");var s={type:"object",properties:o({},e),required:t},u=i.compile(s),a=o({},process.env);if(!u(a))throw new Error(i.errorsText(u.errors,{dataVar:"process.env"}));(void 0===n||n)&&(process.env=a)}; | ||
//# sourceMappingURL=env-vars-validator.cjs.production.min.js.map |
@@ -22,3 +22,2 @@ import Ajv from 'ajv'; | ||
var _ref, _ref$toString, _ref$toString$toLower; | ||
var ajv = /*#__PURE__*/new Ajv({ | ||
@@ -71,9 +70,21 @@ coerceTypes: true, | ||
var currentEnv = (_ref = !!process.env.NODE_ENV && process.env.NODE_ENV !== undefined ? process.env.NODE_ENV : Environment.DEVELOPMENT) == null ? void 0 : (_ref$toString = /*#__PURE__*/_ref.toString()) == null ? void 0 : (_ref$toString$toLower = /*#__PURE__*/_ref$toString.toLowerCase()) == null ? void 0 : /*#__PURE__*/_ref$toString$toLower.trim(); | ||
var isProductionEnv = currentEnv === Environment.PRODUCTION; | ||
var isDevelopmentEnv = currentEnv === Environment.DEVELOPMENT; | ||
var isTestEnv = currentEnv === Environment.TEST; | ||
var isDeployedEnv = currentEnv !== Environment.DEVELOPMENT && currentEnv !== Environment.TEST; | ||
var currentEnv = function currentEnv() { | ||
var _ref, _ref$toString, _ref$toString$toLower; | ||
return (_ref = !!process.env.NODE_ENV && process.env.NODE_ENV !== undefined ? process.env.NODE_ENV : Environment.DEVELOPMENT) == null ? void 0 : (_ref$toString = _ref.toString()) == null ? void 0 : (_ref$toString$toLower = _ref$toString.toLowerCase()) == null ? void 0 : _ref$toString$toLower.trim(); | ||
}; | ||
var isProductionEnv = function isProductionEnv() { | ||
return currentEnv() === Environment.PRODUCTION; | ||
}; | ||
var isDevelopmentEnv = function isDevelopmentEnv() { | ||
return currentEnv() === Environment.DEVELOPMENT; | ||
}; | ||
var isTestEnv = function isTestEnv() { | ||
return currentEnv() === Environment.TEST; | ||
}; | ||
var isDeployedEnv = function isDeployedEnv() { | ||
return currentEnv() !== Environment.DEVELOPMENT && currentEnv() !== Environment.TEST; | ||
}; | ||
export { currentEnv, isDeployedEnv, isDevelopmentEnv, isProductionEnv, isTestEnv, validateEnv }; | ||
//# sourceMappingURL=env-vars-validator.esm.js.map |
@@ -5,6 +5,6 @@ export declare const validateEnv: (validationSchema: object, options?: { | ||
}) => void; | ||
export declare const currentEnv: string; | ||
export declare const isProductionEnv: boolean; | ||
export declare const isDevelopmentEnv: boolean; | ||
export declare const isTestEnv: boolean; | ||
export declare const isDeployedEnv: boolean; | ||
export declare const currentEnv: () => string; | ||
export declare const isProductionEnv: () => boolean; | ||
export declare const isDevelopmentEnv: () => boolean; | ||
export declare const isTestEnv: () => boolean; | ||
export declare const isDeployedEnv: () => boolean; |
{ | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
@@ -37,3 +37,3 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/9d8e089c9e3e1115302f/maintainability)](https://codeclimate.com/github/qlaffont/env-vars-validator/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/9d8e089c9e3e1115302f/test_coverage)](https://codeclimate.com/github/qlaffont/env-vars-validator/test_coverage) ![npm](https://img.shields.io/npm/v/env-vars-validator) ![npm](https://img.shields.io/npm/dm/env-vars-validator) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/env-vars-validator) ![NPM](https://img.shields.io/npm/l/env-vars-validator) | ||
### currentEnv | ||
### currentEnv() | ||
@@ -46,3 +46,3 @@ Default: `development` | ||
### isProductionEnv | ||
### isProductionEnv() | ||
@@ -53,3 +53,3 @@ Return: `Boolean` | ||
### isDevelopmentEnv | ||
### isDevelopmentEnv() | ||
@@ -60,3 +60,3 @@ Return: `Boolean` | ||
### isTestEnv | ||
### isTestEnv() | ||
@@ -67,3 +67,3 @@ Return: `Boolean` | ||
### isDeployedEnv | ||
### isDeployedEnv() | ||
@@ -70,0 +70,0 @@ Return: `Boolean` |
@@ -54,14 +54,14 @@ import Ajv from 'ajv'; | ||
export const currentEnv = ( | ||
!!process.env.NODE_ENV && process.env.NODE_ENV !== undefined | ||
export const currentEnv = () => | ||
(!!process.env.NODE_ENV && process.env.NODE_ENV !== undefined | ||
? process.env.NODE_ENV | ||
: Environment.DEVELOPMENT | ||
) | ||
?.toString() | ||
?.toLowerCase() | ||
?.trim(); | ||
export const isProductionEnv = currentEnv === Environment.PRODUCTION; | ||
export const isDevelopmentEnv = currentEnv === Environment.DEVELOPMENT; | ||
export const isTestEnv = currentEnv === Environment.TEST; | ||
export const isDeployedEnv = | ||
currentEnv !== Environment.DEVELOPMENT && currentEnv !== Environment.TEST; | ||
) | ||
?.toString() | ||
?.toLowerCase() | ||
?.trim(); | ||
export const isProductionEnv = () => currentEnv() === Environment.PRODUCTION; | ||
export const isDevelopmentEnv = () => currentEnv() === Environment.DEVELOPMENT; | ||
export const isTestEnv = () => currentEnv() === Environment.TEST; | ||
export const isDeployedEnv = () => | ||
currentEnv() !== Environment.DEVELOPMENT && currentEnv() !== Environment.TEST; |
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
24255
232