[Gradle, JS] Add more info for check exit code

This commit is contained in:
Ilya Goncharov
2019-11-21 12:31:21 +03:00
parent ac241852de
commit 64380670c5
@@ -13,7 +13,6 @@ import org.gradle.process.internal.ExecActionFactory
import java.io.ByteArrayOutputStream
import java.io.PipedInputStream
import java.io.PipedOutputStream
import java.nio.CharBuffer
import kotlin.concurrent.thread
internal fun Project.execWithProgress(description: String, readStdErr: Boolean = false, body: (ExecAction) -> Unit): ExecResult {
@@ -32,7 +31,7 @@ internal fun Project.execWithProgress(description: String, readStdErr: Boolean =
val buffer = StringBuilder()
while (true) {
val read = reader.read()
if (read == -1) break;
if (read == -1) break
val ch = read.toChar()
if (ch == '\b' || ch == '\n' || ch == '\r') {
if (buffer.isNotEmpty()) {
@@ -55,7 +54,13 @@ internal fun Project.execWithProgress(description: String, readStdErr: Boolean =
val result = exec.execute()
outputReaderThread.join()
if (result.exitValue != 0) {
error(stderr.toString() + "\n" + stdout)
error(
"""
Process '$description' returns ${result.exitValue}
$stderr
$stdout
""".trimIndent()
)
}
result
}