diff --git a/src/errors/index.ts b/src/errors/index.ts index ce120a502..873d61635 100644 --- a/src/errors/index.ts +++ b/src/errors/index.ts @@ -11,8 +11,10 @@ export {ExitError} from './errors/exit' export {ModuleLoadError} from './errors/module-load' export {handle} from './handle' -export function exit(code = 0): never { - throw new ExitError(code) +export function exit(code = 0) { + if (code !== 0) { + throw new ExitError(code) + } } export function error(input: Error | string, options: {exit: false} & PrettyPrintableError): void diff --git a/test/command/command.test.ts b/test/command/command.test.ts index 35f33ea4d..c86f3336e 100644 --- a/test/command/command.test.ts +++ b/test/command/command.test.ts @@ -68,8 +68,7 @@ describe('command', () => { return Command.run([]) }) - .catch(/EEXIT: 0/) - .it('exits with 0') + .it('exits with 0 does not throw error') describe('parse', () => { fancy.stdout().it('has a flag', async (ctx) => {