serverless-dotenv-plugin
Advanced tools
Comparing version 3.7.1 to 3.7.2
{ | ||
"name": "serverless-dotenv-plugin", | ||
"version": "3.7.1", | ||
"version": "3.7.2", | ||
"description": "Preload environment variables with dotenv into serverless.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -18,15 +18,16 @@ 'use strict' | ||
this.serverless.service.provider.environment || {} | ||
this.config = | ||
this.serverless.service.custom && this.serverless.service.custom['dotenv'] | ||
this.logging = | ||
this.config && typeof this.config.logging !== 'undefined' | ||
? this.config.logging | ||
: true | ||
this.required = (this.config && this.config.required) || {} | ||
this.variableExpansion = !( | ||
(this.config && this.config.variableExpansion) === false | ||
this.config = Object.assign( | ||
{ | ||
logging: true, | ||
required: {}, | ||
variableExpansion: true, | ||
}, | ||
(this.serverless.service.custom && | ||
this.serverless.service.custom['dotenv']) || | ||
{}, | ||
) | ||
if (this.config && this.config.dotenvParser) { | ||
this.dotenvParserPath = path.join( | ||
if (this.config.dotenvParser) { | ||
this.config.dotenvParserPath = path.join( | ||
serverless.config.servicePath, | ||
@@ -41,3 +42,3 @@ this.config.dotenvParser, | ||
log(...args) { | ||
if (this.logging) { | ||
if (this.config.logging) { | ||
this.serverless.cli.log(...args) | ||
@@ -95,3 +96,6 @@ } | ||
try { | ||
return require(this.dotenvParserPath)({ dotenv, paths: envFileNames }) | ||
return require(this.config.dotenvParserPath)({ | ||
dotenv, | ||
paths: envFileNames, | ||
}) | ||
} catch (err) { | ||
@@ -109,3 +113,3 @@ throw Object.assign(err, { type: errorTypes.HALT }) | ||
const parsed = dotenv.config({ path: fileName }) | ||
return this.variableExpansion | ||
return this.config.variableExpansion | ||
? dotenvExpand(parsed).parsed | ||
@@ -163,3 +167,3 @@ : parsed.parsed | ||
if (this.required.file === true) { | ||
if (this.config.required.file === true) { | ||
throw Object.assign(new Error(errorMsg), { type: errorTypes.HALT }) | ||
@@ -183,3 +187,3 @@ } | ||
const missingRequiredEnvVars = (this.required.env || []).filter( | ||
const missingRequiredEnvVars = (this.config.required.env || []).filter( | ||
(envVarName) => !envVars[envVarName] && !process.env[envVarName], | ||
@@ -208,3 +212,3 @@ ) | ||
const envVars = this.dotenvParserPath | ||
const envVars = this.config.dotenvParserPath | ||
? this.callDotenvParser(envFileNames) | ||
@@ -211,0 +215,0 @@ : this.parseEnvFiles(envFileNames) |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
196
21228