Skip to content

Commit

Permalink
Merge pull request #129 from breeffy/branch-exit-return-never
Browse files Browse the repository at this point in the history
fix: return never from exit functions
  • Loading branch information
JasonEtco authored Aug 4, 2020
2 parents 00cbaa0 + d878c60 commit 08ffc05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/exit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ export class Exit {
/**
* Stop the action with a "success" status
*/
public success (message?: string) {
public success (message?: string): never {
if (message) this.logger.success(message)
process.exit(SuccessCode)
}

/**
* Stop the action with a "neutral" status
*/
public neutral (message?: string) {
public neutral (message?: string): never {
if (message) this.logger.info(message)
process.exit(NeutralCode)
}

/**
* Stop the action with a "failed" status
*/
public failure (message?: string) {
public failure (message?: string): never {
if (message) this.logger.fatal(message)
process.exit(FailureCode)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Toolkit', () => {

it('logs and fails when the function throws an error', async () => {
const err = new Error('Whoops!')
const exitFailure = jest.fn()
const exitFailure = jest.fn<never, any>()

await Toolkit.run(async twolkit => {
twolkit.exit.failure = exitFailure
Expand Down

0 comments on commit 08ffc05

Please sign in to comment.