Skip to content

Commit

Permalink
feat: don't error on exit code 0
Browse files Browse the repository at this point in the history
  • Loading branch information
peniqliotuv authored and mdonnalley committed Oct 17, 2023
1 parent f77c59c commit c62fb01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/command/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit c62fb01

Please sign in to comment.