serverless-export-env
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "serverless-export-env", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Serverless plugin to export environment variables into a .env file", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -112,2 +112,3 @@ # ⚡️ Serverless Export Env Plugin | ||
* `export-env:resolve` - Resolve CloudFormation references and import variables | ||
* `export-env:apply` - Set environment variables when testing Lambda functions locally | ||
* `export-env:write` - Write environment variables to file | ||
@@ -128,2 +129,5 @@ | ||
### 1.0.2 | ||
* The plugin now properly resolves and sets the environment variables if a Lambda function is invoked locally (`serverless invoke local -f FUNCTION`). This allows seamless as if the function would be deployed on AWS. | ||
### 1.0.1 | ||
@@ -130,0 +134,0 @@ * Corrected plugin naming |
@@ -9,2 +9,3 @@ "use strict"; | ||
const collectFunctionEnvVariables = require("./lib/collectFunctionEnvVariables"); | ||
const setEnvVariables = require("./lib/setEnvVariables"); | ||
const collectOfflineEnvVariables = require("./lib/collectOfflineEnvVariables"); | ||
@@ -29,2 +30,3 @@ const resolveCloudFormationEnvVariables = require("./lib/resolveCloudFormationEnvVariables"); | ||
"resolve", | ||
"apply", | ||
"write" | ||
@@ -39,4 +41,6 @@ ] | ||
"before:offline:start": this.initOfflineHook.bind(this), | ||
"before:invoke:local:invoke": this.initOfflineHook.bind(this), | ||
"export-env:collect": this.collectEnvVars.bind(this), | ||
"export-env:resolve": this.resolveEnvVars.bind(this), | ||
"export-env:apply": this.applyEnvVars.bind(this), | ||
"export-env:write": this.writeEnvVars.bind(this) | ||
@@ -52,4 +56,5 @@ }; | ||
this.isOfflineHooked = true; | ||
this.serverless.pluginManager.run([ "export-env" ]); | ||
return this.serverless.pluginManager.run([ "export-env" ]); | ||
} | ||
return BbPromise.resolve(); | ||
} | ||
@@ -88,2 +93,11 @@ | ||
applyEnvVars() { | ||
return BbPromise.try(() => { | ||
// If this is a local lambda invoke, replace the service environment with the resolved one | ||
if (this.isOfflineHooked) { | ||
setEnvVariables(this.serverless, this.environmentVariables); | ||
} | ||
}); | ||
} | ||
writeEnvVars() { | ||
@@ -90,0 +104,0 @@ return BbPromise.try(() => { |
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
15334
12
219
139