From f63df7ebe41ced8dcdcf0486a788f4215bb9a5e7 Mon Sep 17 00:00:00 2001 From: Hoon Oh Date: Sun, 8 Nov 2020 18:37:21 +0900 Subject: [PATCH] chore: try again --- src/cli.spec.ts | 13 ++++++++++--- src/cli.ts | 3 +-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cli.spec.ts b/src/cli.spec.ts index d59a1bd5..b1962472 100644 --- a/src/cli.spec.ts +++ b/src/cli.spec.ts @@ -11,6 +11,7 @@ import { } from '../test/mock-ec2-endpoints'; import { consoleMockCallJoin } from '../test/utils'; import { main } from './cli'; +import { Console } from 'console'; setBlocking(true); @@ -170,11 +171,17 @@ describe('cli', () => { await new Promise(res => { const s = spawn('node', [cliJsPath, '--help']); - s.stdout.on('data', (data: Buffer) => output.push(data.toString())); - s.on('exit', res); + s.stdout.on('data', (data: Buffer) => { + output.push(data.toString()); + console.log('>>> data', data.toString()); + }); + s.on('close', () => { + console.log('>>> close', output); + res(); + }); }); - console.log(output); + console.log(output.join('')); expect(output.join('')).toMatchSnapshot(); }); diff --git a/src/cli.ts b/src/cli.ts index af755884..cfaad86f 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -311,11 +311,10 @@ export const main = (argvInput?: string[]): Promise => /* istanbul ignore next */ const cleanExit = (): void => { process.stdout.write('\n'); - process.exit(255); + process.exit(); }; process.on('SIGINT', cleanExit); // catch ctrl-c process.on('SIGTERM', cleanExit); // catch kill -process.on('exit', cleanExit); // catch exit /* istanbul ignore if */ if (