From bbb839e90a6b42663d08323c9539e6c5d32c54ed Mon Sep 17 00:00:00 2001 From: Philipp Muens Date: Thu, 2 Mar 2017 11:07:47 +0100 Subject: [PATCH] Colorize executionId --- invoke/lib/invokeFunction.js | 3 ++- invoke/lib/invokeFunction.test.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/invoke/lib/invokeFunction.js b/invoke/lib/invokeFunction.js index 4f9d598..fcd7eff 100644 --- a/invoke/lib/invokeFunction.js +++ b/invoke/lib/invokeFunction.js @@ -3,6 +3,7 @@ /* eslint no-use-before-define: 0 */ const BbPromise = require('bluebird'); +const chalk = require('chalk'); module.exports = { invokeFunction() { @@ -45,7 +46,7 @@ module.exports = { }; } - const log = `${res.executionId}: ${res.result}`; + const log = `${chalk.grey(res.executionId)} ${res.result}`; this.serverless.cli.log(log); diff --git a/invoke/lib/invokeFunction.test.js b/invoke/lib/invokeFunction.test.js index 7346c7c..dcbc1ca 100644 --- a/invoke/lib/invokeFunction.test.js +++ b/invoke/lib/invokeFunction.test.js @@ -2,6 +2,7 @@ const sinon = require('sinon'); const BbPromise = require('bluebird'); +const chalk = require('chalk'); const GoogleProvider = require('../../provider/googleProvider'); const GoogleInvoke = require('../googleInvoke'); @@ -130,7 +131,7 @@ describe('InvokeFunction', () => { }; const expectedOutput = - 'wasdqwerty: Foo bar'; + `${chalk.grey('wasdqwerty')} Foo bar`; return googleInvoke.printResult(result).then(() => { expect(consoleLogStub.calledWithExactly(expectedOutput)).toEqual(true); @@ -140,7 +141,8 @@ describe('InvokeFunction', () => { it('should print an error message to the console when no result was received', () => { const result = {}; - const expectedOutput = 'error: An error occurred while executing your function...'; + const expectedOutput = + `${chalk.grey('error')} An error occurred while executing your function...`; return googleInvoke.printResult(result).then(() => { expect(consoleLogStub.calledWithExactly(expectedOutput)).toEqual(true);