diff --git a/index.js b/index.js index c4ee46b8f..c660ab3ea 100644 --- a/index.js +++ b/index.js @@ -147,17 +147,11 @@ class ServerlessPlugin { 'bref:local:run': () => runLocal(this.serverless, options), 'bref:layers:show': () => listLayers(this.serverless, utils.log), 'before:logs:logs': () => { - /** @type {typeof import('chalk')} */ - // @ts-ignore - const chalk = require.main.require('chalk'); - utils.log(chalk.gray('View, tail, and search logs from all functions with https://dashboard.bref.sh')); + utils.log(this.gray('View, tail, and search logs from all functions with https://dashboard.bref.sh')); utils.log(); }, 'before:metrics:metrics': () => { - /** @type {typeof import('chalk')} */ - // @ts-ignore - const chalk = require.main.require('chalk'); - utils.log(chalk.gray('View all your application\'s metrics with https://dashboard.bref.sh')); + utils.log(this.gray('View all your application\'s metrics with https://dashboard.bref.sh')); utils.log(); }, }; @@ -166,11 +160,8 @@ class ServerlessPlugin { const command = serverless.processedInput.commands[0] || ''; // On successful deploy if (command.startsWith('deploy') && code === 0) { - /** @type {typeof import('chalk')} */ - // @ts-ignore - const chalk = require.main.require('chalk'); utils.log(); - utils.log(chalk.gray('Want a better experience than the AWS console? Try out https://dashboard.bref.sh')); + utils.log(this.gray('Want a better experience than the AWS console? Try out https://dashboard.bref.sh')); } }); } @@ -378,6 +369,16 @@ class ServerlessPlugin { } }); } + + /** + * @param {string} text + * @returns {string} + */ + gray(text) { + const grayText = "\x1b[90m"; + const reset = "\x1b[0m"; + return `${grayText}${text}${reset}`; + } } module.exports = ServerlessPlugin;