Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
Run command as is in Windows even with unbuffered mode. (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunikkk authored Feb 27, 2018
1 parent b04853c commit bd6ae3d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions os/src/main/kotlin/com/gojuno/commander/os/Processes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,15 @@ fun process(
log("$commandAndArgs\n, outputFile = $outputFile")
}

val command: List<String>

when (unbufferedOutput) {
false -> command = commandAndArgs
true -> command = when (os()) {
// Some programs, in particular "emulator" do not always flush output
// after printing so we have to force unbuffered mode to make sure
// that output will be available for consuming.
val command: List<String> = when (unbufferedOutput) {
false -> commandAndArgs
true -> when (os()) {
// Some programs, in particular "emulator" do not always flush output
// after printing so we have to force unbuffered mode to make sure
// that output will be available for consuming.
Linux -> listOf("script", outputFile.absolutePath, "--flush", "-c", commandAndArgs.joinToString(separator = " "))
Mac -> listOf("script", "-F", outputFile.absolutePath, *commandAndArgs.toTypedArray())
Windows -> throw IllegalStateException("Unbuffered output is not supported on Windows")
Windows -> commandAndArgs
}
}

Expand Down

0 comments on commit bd6ae3d

Please sign in to comment.