Skip to content

Commit

Permalink
fix(CLI): Fix resources status log in verbose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Sep 17, 2021
1 parent 084a995 commit bcd8a02
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/plugins/aws/lib/monitorStack.js
Expand Up @@ -3,6 +3,7 @@
const BbPromise = require('bluebird');
const chalk = require('chalk');
const wait = require('timers-ext/promise/sleep');
const identity = require('ext/function/identity');
const ServerlessError = require('../../../serverless-error');
const { log, legacy, progress, style } = require('@serverless/utils/log');

Expand Down Expand Up @@ -59,7 +60,7 @@ module.exports = {
// Loop through stack events
stackEvents.forEach((event) => {
if (loggedEventIds.has(event.EventId)) return;
let eventStatus = event.ResourceStatus || null;
const eventStatus = event.ResourceStatus || null;
// Keep track of stack status
if (
event.ResourceType === 'AWS::CloudFormation::Stack' &&
Expand All @@ -83,14 +84,13 @@ module.exports = {
)
);
if (this.options.verbose) {
if (eventStatus && eventStatus.endsWith('FAILED')) {
eventStatus = chalk.red(eventStatus);
} else if (eventStatus && eventStatus.endsWith('PROGRESS')) {
eventStatus = chalk.yellow(eventStatus);
} else if (eventStatus && eventStatus.endsWith('COMPLETE')) {
eventStatus = chalk.green(eventStatus);
}
let eventLog = `CloudFormation - ${eventStatus} - `;
const decorator = (() => {
if (eventStatus && eventStatus.endsWith('FAILED')) return chalk.red;
if (eventStatus && eventStatus.endsWith('PROGRESS')) return chalk.yellow;
if (eventStatus && eventStatus.endsWith('COMPLETE')) return chalk.green;
return identity;
})();
let eventLog = `CloudFormation - ${decorator(eventStatus)} - `;
eventLog += `${event.ResourceType} - `;
eventLog += `${event.LogicalResourceId}`;
legacy.consoleLog(eventLog);
Expand Down

0 comments on commit bcd8a02

Please sign in to comment.