-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
27 lines (23 loc) · 1.33 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict'
const deployWithParameters = require('./lib/deployWithParameters')
class ServerlessCloudFormationParameterSetter {
constructor (serverless, options) {
try {
this.serverless = serverless
this.provider = this.serverless.getProvider('aws')
let awsDeploy = serverless.pluginManager.plugins.find(p => p.constructor.name === 'AwsDeploy')
awsDeploy.options.cfParameters = serverless.service && serverless.service.custom && serverless.service.custom['cf-parameters']
awsDeploy.createParameters = deployWithParameters.createParameters
awsDeploy.createFallback = Function(awsDeploy.createFallback.toString().replace('Parameters: [],', 'Parameters: this.createParameters(this.options.cfParameters, this.serverless.service.provider.compiledCloudFormationTemplate, false),').slice(18,-1))
awsDeploy.update = Function(
awsDeploy.update.toString()
.replace('Parameters: [],', 'Parameters: this.createParameters(this.options.cfParameters, this.serverless.service.provider.compiledCloudFormationTemplate, true),')
.replace('NO_UPDATE_MESSAGE', '"No updates are to be performed."')
.slice(10,-1))
} catch (e) {
console.log('Error initializing serverless-cloudformation-parameters', e)
throw e
}
}
}
module.exports = ServerlessCloudFormationParameterSetter