From 4ed5e97adcb53564701772bc854397e72d58107b Mon Sep 17 00:00:00 2001 From: Mario Lubenka Date: Sat, 21 Dec 2019 14:21:46 +0100 Subject: [PATCH] Ensure log messages end with new line --- src/Cli.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Cli.ts b/src/Cli.ts index 3fad75f..e3c24b2 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -80,8 +80,12 @@ export class Cli implements CliInterface { } public initEmitter(emitter: EventEmitter) { - emitter.on('log', process.stdout.write.bind(process.stdout)); - emitter.on('error', process.stderr.write.bind(process.stderr)); + emitter.on('log', (args: string) => { + return process.stdout.write.bind(process.stdout)(args + "\n"); + }); + emitter.on('error', (args: string) => { + return process.stderr.write.bind(process.stderr)(args + "\n"); + }); emitter.on('help', (data: any) => emitter.emit('log', data)); } @@ -121,6 +125,6 @@ export class Cli implements CliInterface { return; } commands[requestedCommand].run() - .catch((error) => this.emitter.emit('error', error.toString() + "\n")); + .catch((error) => this.emitter.emit('error', error.toString())); } } \ No newline at end of file