Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPirates committed Nov 29, 2024
1 parent 0b45044 commit df7eadb
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/nl/hannahsten/texifyidea/util/CommandRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit df7eadb

Please sign in to comment.