Skip to content

Commit

Permalink
Look for ROLLBACK_COMPLETE when polling event and exit if found
Browse files Browse the repository at this point in the history
  • Loading branch information
merlin Gaillard committed Nov 7, 2016
1 parent e35b2a0 commit 8a15a2f
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/utils.js
Expand Up @@ -96,10 +96,9 @@ export default function (argv, cloudformation) {
for (let key in params) {
let value = params[key]

// Exit nicely if value is not a string instead of crashing on value.match()
if (typeof(value) !== "string") {
console.error(`Invalid parameter type: ${key} value is a ${typeof(value)}. Only strings are allowed in parameters file.`)
process.exit(1)
if (typeof(value) != "string") {
console.error(`Invalid parameter type: ${key} is a ${typeof(value)}, not a string`)
process
}

let match = value.match(/<<(.+)>>/)
Expand Down Expand Up @@ -264,6 +263,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()
}

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

Expand Down Expand Up @@ -295,8 +306,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

0 comments on commit 8a15a2f

Please sign in to comment.