serverless-dotenv-plugin
Advanced tools
Comparing version 3.4.0 to 3.5.0
@@ -11,2 +11,6 @@ # Changelog | ||
## 3.5.x | ||
* feat: now logs when incompatible configs are set. ([#124](https://github.com/neverendingqs/serverless-dotenv-plugin/pull/124)) | ||
## 3.4.x | ||
@@ -13,0 +17,0 @@ |
30
index.js
@@ -50,3 +50,9 @@ 'use strict' | ||
resolveEnvFileNames(env) { | ||
const basePath = (this.config && this.config.basePath) || '' | ||
if (this.config && this.config.path) { | ||
if (basePath) { | ||
this.log('DOTENV (WARNING): if "path" is set, "basePath" is ignored.') | ||
} | ||
if (Array.isArray(this.config.path)) { | ||
@@ -69,5 +75,2 @@ return this.config.path | ||
const basePath = | ||
this.config && this.config.basePath ? this.config.basePath : '' | ||
const filesNames = dotenvFiles.map((file) => basePath + file) | ||
@@ -117,15 +120,10 @@ | ||
setProviderEnv(envVars) { | ||
let include = false | ||
let exclude = false | ||
const include = (this.config && this.config.include) || [] | ||
const exclude = (this.config && this.config.exclude) || [] | ||
if (this.config && this.config.include) { | ||
include = this.config.include | ||
} | ||
if (include.length > 0) { | ||
if (exclude) { | ||
this.log('DOTENV (WARNING): if "include" is set, "exclude" is ignored.') | ||
} | ||
if (this.config && this.config.exclude && !include) { | ||
// Don't allow both include and exclude to be specified | ||
exclude = this.config.exclude | ||
} | ||
if (include) { | ||
Object.keys(envVars) | ||
@@ -136,4 +134,3 @@ .filter((key) => !include.includes(key)) | ||
}) | ||
} | ||
if (exclude) { | ||
} else if (exclude.length > 0) { | ||
Object.keys(envVars) | ||
@@ -145,2 +142,3 @@ .filter((key) => exclude.includes(key)) | ||
} | ||
Object.keys(envVars).forEach((key) => { | ||
@@ -147,0 +145,0 @@ this.log('\t - ' + key) |
{ | ||
"name": "serverless-dotenv-plugin", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "Preload environment variables with dotenv into serverless.", | ||
@@ -21,2 +21,5 @@ "main": "index.js", | ||
"author": "Colyn Brown <colyn.brown@gmail.com>", | ||
"contributors": [ | ||
"Mark Tse <mark.tse@neverendingqs.com> (https://neverendingqs.com/)" | ||
], | ||
"license": "MIT", | ||
@@ -23,0 +26,0 @@ "bugs": { |
@@ -77,3 +77,3 @@ # serverless-dotenv-plugin | ||
Again, remember that when you deploy your service, the plugin will inject these environment vars into every lambda functions you have and will therefore allow you to reference them as `process.env.AUTH0_CLIENT_ID` (Nodejs example). | ||
Again, remember that when you deploy your service, the plugin will inject these environment vars into every lambda functions you have and will therefore allow you to reference them as `process.env.AUTH0_CLIENT_ID` (Nodejs example). If this behaviour is not desireable, set `include` to `[]`. | ||
@@ -80,0 +80,0 @@ |
@@ -145,2 +145,13 @@ process.env.TEST_SLS_DOTENV_PLUGIN_ENV1 = 'env1' | ||
}) | ||
it('logs an error if basePath is also set', function () { | ||
const path = '.env.unittest' | ||
this.serverless.service.custom.dotenv.basePath = 'base/path/' | ||
this.serverless.service.custom.dotenv.path = path | ||
this.plugin.resolveEnvFileNames('env').should.deep.equal([path]) | ||
this.serverless.cli.log.should.have.been.calledWith( | ||
sinon.match(/basePath/), | ||
) | ||
}) | ||
}) | ||
@@ -441,2 +452,6 @@ | ||
}) | ||
this.serverless.cli.log.should.have.been.calledWith( | ||
sinon.match(/exclude/), | ||
) | ||
}) | ||
@@ -443,0 +458,0 @@ |
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
59421
26
1068