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

Run command as is in Windows even with unbuffered mode. #14

Merged
merged 1 commit into from
Feb 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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