diff --git a/lib/plugins/emit/index.js b/lib/plugins/emit/index.js index ae0e81660..72f395c21 100644 --- a/lib/plugins/emit/index.js +++ b/lib/plugins/emit/index.js @@ -1,5 +1,6 @@ 'use strict'; +const os = require('os'); const BbPromise = require('bluebird'); const fdk = require('@serverless/fdk'); const path = require('path'); @@ -134,14 +135,12 @@ class Emit { .then(() => { const msg = `${prefix}Emitted the event ${name} as datatype ${emitParams.dataType || 'application/json'}:`; - this.serverless.cli.consoleLog(`${msg}`); - this.serverless.cli.consoleLog(prettifyValue(data)); + this.serverless.cli.consoleLog(`${msg}${os.EOL}${prettifyValue(data)}`); }) .catch(() => { const msg = `${prefix}Failed to emit the event ${name} as datatype ${emitParams.dataType || 'application/json'}:`; - this.serverless.cli.consoleLog(`${msg}`); - this.serverless.cli.consoleLog(prettifyValue(data)); + this.serverless.cli.consoleLog(`${msg}${os.EOL}${prettifyValue(data)}`); throw new Error(`Failed to emit the event ${name}`); }); } diff --git a/lib/plugins/emit/index.test.js b/lib/plugins/emit/index.test.js index 009df86f4..d101909d0 100644 --- a/lib/plugins/emit/index.test.js +++ b/lib/plugins/emit/index.test.js @@ -141,11 +141,10 @@ describe('Emit', () => { data: emit.data, }) ).to.equal(true); - expect(logStub.calledOnce).to.equal(true); - const msgPartOne = 'Successfully emitted the event userCreated as datatype'; - expect( - logStub.calledWithExactly(`${msgPartOne} application/json with:\n{"key":"value"}`) - ).to.equal(true); + expect(logStub.getCall(0).args[0]).to.equal( + // eslint-disable-next-line max-len + '\u001b[38;5;178m Serverless \u001b[39mEmitted the event userCreated as datatype application/json:\n \u001b[38;5;243m{\u001b[39m\n\u001b[38;5;243m "key": "value"\u001b[39m\n\u001b[38;5;243m }\u001b[39m' + ); }); }); @@ -162,11 +161,10 @@ describe('Emit', () => { dataType: 'text/plain', }) ).to.equal(true); - expect(logStub.calledOnce).to.equal(true); - const msgPartOne = 'Successfully emitted the event userCreated as datatype'; - expect( - logStub.calledWithExactly(`${msgPartOne} text/plain with:\n"This is a message"`) - ).to.equal(true); + expect(logStub.getCall(0).args[0]).to.equal( + // eslint-disable-next-line max-len + '\u001b[38;5;178m Serverless \u001b[39mEmitted the event userCreated as datatype text/plain:\n \u001b[38;5;243m"This is a message"\u001b[39m' + ); }); }); });