Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 27 additions & 29 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,35 +805,7 @@ Lambda.prototype._deployToRegion = function (program, params, region) {
// Checking function
return lambda.getFunction({
'FunctionName': params.FunctionName
}, (err) => {
if (err) {
// Function does not exist
return _this._uploadNew(lambda, params).then((results) => {
console.log('=> Zip file(s) done uploading. Results follow: ')
console.log(results)

return Promise.all([
_this._updateEventSources(
lambda,
params.FunctionName,
[],
eventSourceList.EventSourceMappings
),
_this._updateScheduleEvents(
scheduleEvents,
results.FunctionArn,
eventSourceList.ScheduleEvents
)
]).then((results) => {
resolve(results)
}).catch((err) => {
reject(err)
})
}).catch((err) => {
reject(err)
})
}

}).promise().then(() => {
// Function exists
_this._listEventSourceMappings(lambda, {
'FunctionName': params.FunctionName
Expand Down Expand Up @@ -862,6 +834,32 @@ Lambda.prototype._deployToRegion = function (program, params, region) {
reject(err)
})
})
}).catch(() => {
// Function does not exist
return _this._uploadNew(lambda, params).then((results) => {
console.log('=> Zip file(s) done uploading. Results follow: ')
console.log(results)

return Promise.all([
_this._updateEventSources(
lambda,
params.FunctionName,
[],
eventSourceList.EventSourceMappings
),
_this._updateScheduleEvents(
scheduleEvents,
results.FunctionArn,
eventSourceList.ScheduleEvents
)
]).then((results) => {
resolve(results)
}).catch((err) => {
reject(err)
})
}).catch((err) => {
reject(err)
})
})
})
}
Expand Down