Add the "@actions/exit" package

It is useful to have the exit logic separated into its own package
This commit is contained in:
Jonathan Clem
2019-04-20 10:52:56 -04:00
parent 1e32709630
commit cca9523c73
7 changed files with 130 additions and 0 deletions

43
packages/exit/src/exit.ts Normal file
View 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)
}