0.1.7 • Published 7 months ago
main-function v0.1.7
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.