Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
fix: scope exitErr
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 19, 2018
1 parent 75eba57 commit 01eac05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export default function (o: Rx.Subject<Message>): Rx.Observable<any> {
// and can be ignored
try {
if (err.code === 'EPIPE') return
if (typeof err.exitCode === 'number') {
process.exit(err.exitCode)
if (err['cli-ux'] && typeof err['cli-ux'].exitCode === 'number') {
process.exit(err['cli-ux'].exitCode)
} else {
const cli = new CLI(scope)
cli.fatal(err, {exit: false})
Expand Down
6 changes: 4 additions & 2 deletions src/exit.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
export class ExitError extends Error {
public exitCode: number
public 'cli-ux': {
exitCode: number
}
public code: 'EEXIT'
public error?: Error

constructor(status: number, error?: Error) {
const code = 'EEXIT'
super(error ? error.message : `${code}: ${status}`)
this.error = error
this.exitCode = status
this['cli-ux'] = {exitCode: status}
this.code = code
}
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class CLI {
const code = getExitCode(options)
if (code === false) return
let exitErr: ExitError = error as any
exitErr.exitCode = exitErr.exitCode || code
exitErr['cli-ux'] = exitErr['cli-ux'] || {exitCode: code}
throw exitErr
}

Expand Down

0 comments on commit 01eac05

Please sign in to comment.