Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Look for ROLLBACK_COMPLETE when polling event and exit if found #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@ export default function (argv, cloudformation) {
}

function pollEvents (stackName, actionName, matches, callback, opts = {}) {
const failureMatches = [
[ 'LogicalResourceId', stackName ],
[ 'ResourceStatus', 'ROLLBACK_COMPLETE' ]
]
const failureCallback = function (err) {
if (err) {
throw err
}
console.log(`${stackName} failed!`.red)
process.exit()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably exit with 1 if it's a failure

}

function checkEvents (lastDate) {
const now = new Date()

Expand Down Expand Up @@ -295,8 +307,16 @@ export default function (argv, cloudformation) {
spinner.destroy()
return callback()
}
if (failureMatches.every(function (match) {
return events[i][match[0]] === match[1]
})) {
spinner.destroy()
return failureCallback()
}
}



return next()

function next () {
Expand Down