mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-01 02:33:23 +08:00
Add the "@actions/exit" package
It is useful to have the exit logic separated into its own package
This commit is contained in:
43
packages/exit/src/exit.ts
Normal file
43
packages/exit/src/exit.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* The code to exit an action
|
||||
*/
|
||||
export enum ExitCode {
|
||||
/**
|
||||
* A code indicating that the action was successful
|
||||
*/
|
||||
Success = 0,
|
||||
|
||||
/**
|
||||
* A code indicating that the action was a failure
|
||||
*/
|
||||
Failure = 1,
|
||||
|
||||
/**
|
||||
* A code indicating that the action is complete, but neither succeeded nor failed
|
||||
*/
|
||||
Neutral = 78
|
||||
}
|
||||
|
||||
// TODO: These exit codes may not behave as expected on the new runtime, due to
|
||||
// complexities of async logging and sync exiting.
|
||||
|
||||
/**
|
||||
* Exit the action as a success.
|
||||
*/
|
||||
export function success() {
|
||||
process.exit(ExitCode.Success)
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit the action as a failure.
|
||||
*/
|
||||
export function failure() {
|
||||
process.exit(ExitCode.Failure)
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit the action neither a success or a failure
|
||||
*/
|
||||
export function neutral() {
|
||||
process.exit(ExitCode.Neutral)
|
||||
}
|
||||
Reference in New Issue
Block a user