serverless-export-env
Advanced tools
Comparing version 1.1.2 to 1.1.3
{ | ||
"name": "serverless-export-env", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Serverless plugin to export environment variables into a .env file", | ||
@@ -17,3 +17,3 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"bluebird": "^3.5.0", | ||
"bluebird": "^3.5.1", | ||
"lodash": "^4.17.4" | ||
@@ -20,0 +20,0 @@ }, |
@@ -134,2 +134,6 @@ # ⚡️ Serverless Export Env Plugin | ||
### 1.1.3 | ||
* Fixed an issue with `AWS::AccountId` being resolved as `[Object Promise]` | ||
instead of the actual value. | ||
### 1.1.2 | ||
@@ -141,3 +145,3 @@ * Fixed an issue with CloudFormation resources not being resolved properly if | ||
* Fix issue with multiple environment variables for function (thanks to | ||
[@Nevon](github.com/Nevon)). | ||
[@Nevon](https://github.com/Nevon)). | ||
@@ -144,0 +148,0 @@ ### 1.1.0 |
@@ -49,24 +49,24 @@ "use strict"; | ||
function mapValue(value, key) { | ||
let resolved = value; | ||
function mapValue(value) { | ||
if (_.isObject(value)) { | ||
if (value.Ref) { | ||
if (value.Ref === "AWS::Region") { | ||
resolved = AWS.getRegion(); | ||
return AWS.getRegion(); | ||
} | ||
else if (value.Ref === "AWS::AccountId") { | ||
resolved = AWS.getAccountId(); | ||
return AWS.getAccountId(); | ||
} | ||
else if (value.Ref === "AWS::StackId") { | ||
resolved = _.get(_.first(resources), "StackId"); | ||
return _.get(_.first(resources), "StackId"); | ||
} | ||
else if (value.Ref === "AWS::StackName") { | ||
resolved = AWS.naming.getStackName(); | ||
return AWS.naming.getStackName(); | ||
} | ||
else { | ||
const resource = _.find(resources, [ "LogicalResourceId", value.Ref ]); | ||
resolved = _.get(resource, "PhysicalResourceId", null); | ||
const resolved = _.get(resource, "PhysicalResourceId", null); | ||
if (_.isNil(resolved)) { | ||
serverless.cli.log(`WARNING: Failed to resolve reference ${value.Ref}`); | ||
} | ||
return BbPromise.resolve(resolved); | ||
} | ||
@@ -77,23 +77,28 @@ } | ||
const resource = _.find(exports, [ "Name", importKey ]); | ||
resolved = _.get(resource, "Value", null); | ||
const resolved = _.get(resource, "Value", null); | ||
if (_.isNil(resolved)) { | ||
serverless.cli.log(`WARNING: Failed to resolve import value ${importKey}`); | ||
} | ||
return BbPromise.resolve(resolved); | ||
} | ||
else if (value["Fn::Join"]) { | ||
resolved = ""; | ||
// Join has two Arguments. first the delimiter and second the values | ||
let delimiter = value["Fn::Join"][0]; | ||
let parts = value["Fn::Join"][1]; | ||
_.forEach(parts, (v, i) => { | ||
resolved += mapValue(v) + (i < parts.length - 1 ? delimiter : ""); | ||
}); | ||
return BbPromise.map(parts, v => mapValue(v)) | ||
.then(resolvedParts => _.join(resolvedParts, delimiter)); | ||
} | ||
process.env.SLS_DEBUG && key && serverless.cli.log(`Resolved environment variable ${key}: ${JSON.stringify(resolved)}`); | ||
} | ||
return resolved; | ||
return BbPromise.resolve(value); | ||
} | ||
return _.mapValues(envVars, (value, key) => mapValue(value, key)); | ||
return BbPromise.reduce(_.keys(envVars), (result, key) => { | ||
return BbPromise.resolve(mapValue(envVars[key])) | ||
.then(resolved => { | ||
process.env.SLS_DEBUG && serverless.cli.log(`Resolved environment variable ${key}: ${JSON.stringify(resolved)}`); | ||
result[key] = resolved; | ||
return BbPromise.resolve(result); | ||
}); | ||
}, {}); | ||
}); | ||
@@ -100,0 +105,0 @@ } |
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
17992
273
168
11
Updatedbluebird@^3.5.1