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

Commit 01eac05

Browse files
committed
fix: scope exitErr
1 parent 75eba57 commit 01eac05

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/errors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ export default function (o: Rx.Subject<Message>): Rx.Observable<any> {
6161
// and can be ignored
6262
try {
6363
if (err.code === 'EPIPE') return
64-
if (typeof err.exitCode === 'number') {
65-
process.exit(err.exitCode)
64+
if (err['cli-ux'] && typeof err['cli-ux'].exitCode === 'number') {
65+
process.exit(err['cli-ux'].exitCode)
6666
} else {
6767
const cli = new CLI(scope)
6868
cli.fatal(err, {exit: false})

src/exit.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
export class ExitError extends Error {
2-
public exitCode: number
2+
public 'cli-ux': {
3+
exitCode: number
4+
}
35
public code: 'EEXIT'
46
public error?: Error
57

68
constructor(status: number, error?: Error) {
79
const code = 'EEXIT'
810
super(error ? error.message : `${code}: ${status}`)
911
this.error = error
10-
this.exitCode = status
12+
this['cli-ux'] = {exitCode: status}
1113
this.code = code
1214
}
1315
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class CLI {
3737
const code = getExitCode(options)
3838
if (code === false) return
3939
let exitErr: ExitError = error as any
40-
exitErr.exitCode = exitErr.exitCode || code
40+
exitErr['cli-ux'] = exitErr['cli-ux'] || {exitCode: code}
4141
throw exitErr
4242
}
4343

0 commit comments

Comments
 (0)