1
0
Fork 0

fix: rename main app method to main, remove redundant wrapper

This commit is contained in:
ssube 2019-09-29 10:03:26 -05:00
parent e2a40e0ae9
commit 0e8ac4627c
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
3 changed files with 8 additions and 15 deletions

View File

@ -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<void> {
export async function main(argv: Array<string>): Promise<number> {
// 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;
}

View File

@ -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<string>): Promise<number> {
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);

View File

@ -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);
});