fix: rename main app method to main, remove redundant wrapper
This commit is contained in:
parent
e2a40e0ae9
commit
0e8ac4627c
|
@ -3,7 +3,8 @@ import { VERSION_INFO } from './version';
|
||||||
import JSON_DATA from './resource/json.json';
|
import JSON_DATA from './resource/json.json';
|
||||||
import YAML_DATA from './resource/yaml.yml';
|
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
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
14
src/index.ts
14
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.
|
* 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) => {
|
main(process.argv).then((status) => process.exit(status)).catch((err: Error) => {
|
||||||
/* tslint:disable-next-line:no-console */
|
/* tslint:disable-next-line:no-console */
|
||||||
console.error('uncaught error during main:', err);
|
console.error('uncaught error during main:', err);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { spy } from 'sinon';
|
import { spy } from 'sinon';
|
||||||
|
|
||||||
import { createApp } from '../src/app';
|
import { main } from '../src/app';
|
||||||
import { describeLeaks, itLeaks } from './helpers/async';
|
import { describeLeaks, itLeaks } from './helpers/async';
|
||||||
|
|
||||||
describeLeaks('app', async () => {
|
describeLeaks('app', async () => {
|
||||||
|
@ -9,7 +9,7 @@ describeLeaks('app', async () => {
|
||||||
/* tslint:disable-next-line:no-console no-unbound-method */
|
/* tslint:disable-next-line:no-console no-unbound-method */
|
||||||
const logSpy = spy(console, 'log');
|
const logSpy = spy(console, 'log');
|
||||||
|
|
||||||
await createApp();
|
await main([]);
|
||||||
|
|
||||||
expect(logSpy).to.have.callCount(1);
|
expect(logSpy).to.have.callCount(1);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue