1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-25 16:07:12 -07:00

Added ignoreInputStream, ignoreErrorStream and ignoreExitvalue to the application plugin.

This commit is contained in:
Erik C. Thauvin 2017-11-08 01:05:16 -08:00
parent be40f5c81d
commit 20a01f8de0
2 changed files with 20 additions and 4 deletions

View file

@ -19,6 +19,7 @@ class RunCommandInfo {
*/
var useErrorStreamAsErrorIndicator : Boolean = true
var useInputStreamAsErrorIndicator : Boolean = false
var ignoreExitValue : Boolean = false
var errorCallback: Function1<List<String>, Unit> = NewRunCommand.DEFAULT_ERROR
var successCallback: Function1<List<String>, Unit> = NewRunCommand.DEFAULT_SUCCESS
@ -89,10 +90,14 @@ open class NewRunCommand(val info: RunCommandInfo) {
// Check to see if the command succeeded
val isSuccess =
if (info.containsErrors != null) ! info.containsErrors!!(error)
else isSuccess(returnCode, input, error)
else isSuccess(if (info.ignoreExitValue) true else returnCode, input, error)
if (isSuccess) {
info.successCallback(input)
if (!info.useErrorStreamAsErrorIndicator) {
info.successCallback(error + input)
} else {
info.successCallback(input)
}
} else {
info.errorCallback(error + input)
}
@ -105,7 +110,7 @@ open class NewRunCommand(val info: RunCommandInfo) {
* have various ways to signal errors.
*/
open protected fun isSuccess(isSuccess: Boolean, input: List<String>, error: List<String>) : Boolean {
var hasErrors = ! isSuccess
var hasErrors: Boolean = ! isSuccess
if (info.useErrorStreamAsErrorIndicator && ! hasErrors) {
hasErrors = hasErrors || error.isNotEmpty()
}