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

serverless-export-env

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-export-env - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

src/lib/collectStackOutputs.js

10

package.json
{
"name": "serverless-export-env",
"version": "1.3.1",
"version": "1.4.0",
"description": "Serverless plugin to export environment variables into a .env file",

@@ -21,8 +21,8 @@ "main": "src/index.js",

"bluebird": "^3.7.2",
"lodash": "^4.17.15"
"lodash": "^4.17.20"
},
"devDependencies": {
"eslint": "^7.0.0",
"eslint-plugin-prettier": "^3.1.3",
"prettier": "^2.0.5"
"eslint": "^7.10.0",
"eslint-plugin-prettier": "^3.1.4",
"prettier": "^2.1.2"
},

@@ -29,0 +29,0 @@ "prettier": {

@@ -118,2 +118,6 @@ # ⚡️ Serverless Export Env Plugin

### 1.3.1
- Explicitly set environment variables during local invocation of the Lambda (`sls invoke local`)
### 1.3.0

@@ -120,0 +124,0 @@

@@ -14,2 +14,3 @@ "use strict";

const collectResourcesOutputs = require("./lib/collectResourcesOutputs");
const collectStackOutputs = require("./lib/collectStackOutputs");

@@ -59,23 +60,25 @@ /**

// collect global environment variables
const globalEnvironment = this.serverless.service.provider.environment;
_.assign(envVars, globalEnvironment);
return collectStackOutputs(this.serverless).then((stackOutputs) => {
// collect global environment variables
const globalEnvironment = this.serverless.service.provider.environment;
_.assign(envVars, globalEnvironment);
// collect Resources Outputs
const resourcesOutputs = collectResourcesOutputs(this.serverless);
_.assign(envVars, resourcesOutputs);
// collect Resources Outputs
const resourcesOutputs = collectResourcesOutputs(this.serverless, stackOutputs);
_.assign(envVars, resourcesOutputs);
// collect environment variables of functions
const functionEnvironment = collectFunctionEnvVariables(this.serverless);
_.assign(envVars, functionEnvironment);
// collect environment variables of functions
const functionEnvironment = collectFunctionEnvVariables(this.serverless);
_.assign(envVars, functionEnvironment);
// collect environment variables for serverless offline
if (this.isOfflineHooked) {
const offlineEnvVars = collectOfflineEnvVariables(this.serverless, this.options);
_.assign(envVars, offlineEnvVars);
}
// collect environment variables for serverless offline
if (this.isOfflineHooked) {
const offlineEnvVars = collectOfflineEnvVariables(this.serverless, this.options);
_.assign(envVars, offlineEnvVars);
}
process.env.SLS_DEBUG && this.serverless.cli.log(`Found ${_.size(envVars)} environment variable(s)`);
this.environmentVariables = envVars;
return BbPromise.resolve();
process.env.SLS_DEBUG && this.serverless.cli.log(`Found ${_.size(envVars)} environment variable(s)`);
this.environmentVariables = envVars;
return BbPromise.resolve();
});
});

@@ -104,3 +107,3 @@ }

const params = this.serverless.service.custom["export-env"];
const params = _.get(this.serverless, 'service.custom.export-env');

@@ -107,0 +110,0 @@ let filename = this.envFileName;

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

* @param {Serverless} serverless - Serverless Instance
* @param {Array[Map]} stackOutputs - an array of stack outputs
* @returns {String[]} Returns a list of environment variables
*/
function collectResourcesOutputs(serverless) {
function collectResourcesOutputs(serverless, stackOutputs = {}) {
const outputs = _.get(serverless, "service.resources.Outputs", []);

@@ -17,3 +18,7 @@ const envVars = {};

_.each(_.keys(outputs), (key) => {
const value = outputs[key].Value;
const outputValue = _.find(stackOutputs, ["OutputKey", key]);
const value =
outputValue !== undefined && outputValue["OutputValue"] !== undefined
? outputValue["OutputValue"]
: outputs[key].Value;
const envVarKey = _.toUpper(_.snakeCase(key));

@@ -20,0 +25,0 @@ const envVar = { [envVarKey]: value };

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