Skip to content

Commit

Permalink
feat(CLI): Add timer to final message in modern logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Sep 15, 2021
1 parent 26b8bd5 commit 7828cc7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/classes/PluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ class PluginManager {
* Called by the CLI to start a public command.
*/
async run(commandsArray) {
this.commandRunStartTime = Date.now();
if (resolveCliInput().commands[0] !== 'plugin') {
// first initialize hooks
for (const { hook } of this.getHooks(['initialize'])) {
Expand Down
14 changes: 12 additions & 2 deletions lib/plugins/aws/deploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ class AwsDeploy {
log.notice(
`\n${style.noticeSymbol('✔')} Service deployed to stack ${this.serverless
.getProvider('aws')
.naming.getStackName()}\n`
.naming.getStackName()} ${style.aside(
`(${Math.floor(
(Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000
)}s)`
)}\n`
);
},

Expand All @@ -146,7 +150,13 @@ class AwsDeploy {
if (isDeployCommand && !this.options.function) {
log.error(); // In order to ensure extra new line before the error message
log.error(
`Stack ${serverless.getProvider('aws').naming.getStackName()} failed to deploy`
`Stack ${serverless
.getProvider('aws')
.naming.getStackName()} failed to deploy ${style.aside(
`(${Math.floor(
(Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000
)}s)`
)}`
);
}
},
Expand Down
8 changes: 7 additions & 1 deletion lib/plugins/aws/deploy/lib/checkForChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ module.exports = {

const message = ['Service files not changed. Skipping deployment...'].join('');
legacy.log(message, 'Serverless', { color: 'orange' });
log.notice(`\n${style.noticeSymbol('∅')} No changes to deploy. Deployment skipped.`);
log.notice(
`\n${style.noticeSymbol('∅')} No changes to deploy. Deployment skipped. ${style.aside(
`(${Math.floor(
(Date.now() - this.serverless.pluginManager.commandRunStartTime) / 1000
)}s)`
)}`
);
}
});
}
Expand Down

0 comments on commit 7828cc7

Please sign in to comment.