main-function
v0.1.7
Published
A simple wrapper that handles error and return code.
Downloads
39
Readme
Main Function
A simple wrapper that handles error and return code.
Install
yarn add main-function
Usage
import main, {ProgramError} from 'main-function';
main(async (args: string[]) => {
// Throw an `ProgramError` to exit:
throw new ProgramError(0, 'Some friendly error message');
// Or throw a normal error (will print error stack and exit with code `1`):
throw new Error():
// Optional return statement for exit code:
return 0;
});
License
MIT License.