From df7eadbc52fb0a75e9dc066b68c8539237a832f7 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Fri, 29 Nov 2024 17:40:31 +0100 Subject: [PATCH] Linting --- .../texifyidea/util/CommandRunner.kt | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/util/CommandRunner.kt b/src/nl/hannahsten/texifyidea/util/CommandRunner.kt index 3ef7831dc..23e02fc3e 100644 --- a/src/nl/hannahsten/texifyidea/util/CommandRunner.kt +++ b/src/nl/hannahsten/texifyidea/util/CommandRunner.kt @@ -52,18 +52,24 @@ suspend fun runCommandNonBlocking( process.outputWriter().use { if (input != null) it.write(input) } val output = if (!discardOutput) async { process.inputReader().use { it.readText() } } else null - val error = if (!discardOutput) async { process.errorReader().use { - try { - it.readText() - } catch (e: IOException) { - // In some case directly after IDE start, the stream may be closed already, so ignore that - if (e.message?.contains("Stream closed") == true) { - Log.info("Ignored closed stream: " + e.message) - e.message + val error = if (!discardOutput) { + async { + process.errorReader().use { + try { + it.readText() + } + catch (e: IOException) { + // In some case directly after IDE start, the stream may be closed already, so ignore that + if (e.message?.contains("Stream closed") == true) { + Log.info("Ignored closed stream: " + e.message) + e.message + } + else throw e + } } - else throw e } - } } else null + } + else null withTimeoutOrNull(1_000 * timeout) { process.awaitExit()