New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

serverless-dotenv-plugin

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-dotenv-plugin - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

4

CHANGELOG.md

@@ -10,2 +10,6 @@ # Changelog

## 3.3.0
* feat: adding variableExpansion option to turn off variable expansion. ([#116](https://github.com/neverendingqs/serverless-dotenv-plugin/pull/116))
## 3.2.0

@@ -12,0 +16,0 @@

12

index.js

@@ -24,2 +24,5 @@ 'use strict'

this.required = (this.config && this.config.required) || {}
this.variableExpansion = !(
(this.config && this.config.variableExpansion) === false
)

@@ -79,5 +82,8 @@ this.loadEnv(this.getEnvironment(options))

parseEnvFiles(envFileNames) {
const envVarsArray = envFileNames.map(
(fileName) => dotenvExpand(dotenv.config({ path: fileName })).parsed,
)
const envVarsArray = envFileNames.map((fileName) => {
const parsed = dotenv.config({ path: fileName })
return this.variableExpansion
? dotenvExpand(parsed).parsed
: parsed.parsed
})

@@ -84,0 +90,0 @@ return envVarsArray.reduce((acc, curr) => ({ ...acc, ...curr }), {})

{
"name": "serverless-dotenv-plugin",
"version": "3.2.0",
"version": "3.3.0",
"description": "Preload environment variables with dotenv into serverless.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -114,2 +114,5 @@ # serverless-dotenv-plugin

file: true
# default: true
variableExpansion: false
```

@@ -142,3 +145,9 @@

* variableExpansion: true|false (default true)
* By default, variables can reference other variables
* E.g. `INNER_ENV=innerenv, OUTER_ENV=hi-$INNER_ENV`, would resolve to `INNER_ENV=innerenv, OUTER_ENV=hi-innerenv`
* Setting this to `false` will disable this feature
* E.g. `INNER_ENV=innerenv, OUTER_ENV=hi-$INNER_ENV`, would resolve to `INNER_ENV=innerenv, OUTER_ENV=hi-$INNER_ENV`
## Examples

@@ -145,0 +154,0 @@

@@ -400,3 +400,93 @@ const chai = require('chai')

})
it('does not use `dotenv-expand` when `variableExpansion` is set to `false`', function () {
const fileName = '.env'
const envVars = {
env1: 'env1value',
env2: 'env2value',
env3: 'env3value',
}
const serverless = {
cli: {
log: this.sandbox.stub(),
},
service: {
custom: {
dotenv: {
variableExpansion: false,
},
},
provider: {},
},
}
const plugin = new this.ServerlessPlugin(serverless, this.options)
const resolveEnvFileNames = this.sandbox.stub(
plugin,
'resolveEnvFileNames',
)
resolveEnvFileNames.withArgs(this.env).returns([fileName])
this.requireStubs.dotenv.config
.withArgs({ path: fileName })
.returns({ parsed: envVars })
plugin.loadEnv(this.env)
serverless.service.provider.environment.should.deep.equal({
env1: envVars.env1,
env2: envVars.env2,
env3: envVars.env3,
})
this.requireStubs['dotenv-expand'].should.not.have.been.called
})
it('runs with defaults when there are no configs', function () {
const fileName = '.env'
const envVars = {
env1: 'env1value',
env2: 'env2value',
env3: 'env3value',
}
const serverless = {
cli: {
log: this.sandbox.stub(),
},
service: {
custom: {},
provider: {},
},
}
const plugin = new this.ServerlessPlugin(serverless, this.options)
const resolveEnvFileNames = this.sandbox.stub(
plugin,
'resolveEnvFileNames',
)
resolveEnvFileNames.withArgs(this.env).returns([fileName])
this.requireStubs.dotenv.config
.withArgs({ path: fileName })
.returns({ parsed: envVars })
this.requireStubs['dotenv-expand']
.withArgs({ parsed: envVars })
.returns({ parsed: envVars })
plugin.loadEnv(this.env)
serverless.service.provider.environment.should.deep.equal({
env1: envVars.env1,
env2: envVars.env2,
env3: envVars.env3,
})
})
})
})
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