From 0e8ac4627c60a4c10b3868da2ca6cd01cccd26e3 Mon Sep 17 00:00:00 2001 From: ssube Date: Sun, 29 Sep 2019 10:03:26 -0500 Subject: [PATCH] fix: rename main app method to main, remove redundant wrapper --- src/app.ts | 5 +++-- src/index.ts | 14 +++----------- test/TestApp.ts | 4 ++-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/app.ts b/src/app.ts index 42b9924..1954d04 100644 --- a/src/app.ts +++ b/src/app.ts @@ -3,7 +3,8 @@ import { VERSION_INFO } from './version'; import JSON_DATA from './resource/json.json'; import YAML_DATA from './resource/yaml.yml'; -export async function createApp(): Promise { +export async function main(argv: Array): Promise { // tslint:disable-next-line:no-console - console.log('Hello World!', VERSION_INFO, JSON_DATA, YAML_DATA); + console.log('Hello World!', VERSION_INFO, JSON_DATA, YAML_DATA, argv); + return 1; } diff --git a/src/index.ts b/src/index.ts index 87b1543..4412de1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,18 +1,10 @@ -import { createApp } from './app'; +import { main } from './app'; + +const STATUS_ERROR = 1; /** * This is the main entry-point to the program and the only file not included in the main bundle. - * - * Keep the main method minimal, since this file cannot be tested. */ -const STATUS_SUCCESS = 0; -const STATUS_ERROR = 1; - -async function main(argv: Array): Promise { - await createApp(); - return STATUS_SUCCESS; -} - main(process.argv).then((status) => process.exit(status)).catch((err: Error) => { /* tslint:disable-next-line:no-console */ console.error('uncaught error during main:', err); diff --git a/test/TestApp.ts b/test/TestApp.ts index 0e6cc8b..5336563 100644 --- a/test/TestApp.ts +++ b/test/TestApp.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { spy } from 'sinon'; -import { createApp } from '../src/app'; +import { main } from '../src/app'; import { describeLeaks, itLeaks } from './helpers/async'; describeLeaks('app', async () => { @@ -9,7 +9,7 @@ describeLeaks('app', async () => { /* tslint:disable-next-line:no-console no-unbound-method */ const logSpy = spy(console, 'log'); - await createApp(); + await main([]); expect(logSpy).to.have.callCount(1); });