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

Commit

Permalink
Redirect output on Windows. (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunikkk authored May 16, 2018
1 parent 51b191b commit 3bc85a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun connectedAdbDevices(): Observable<Set<AdbDevice>> = process(listOf(adb, "dev
.retry { retryCount, exception ->
val shouldRetry = retryCount < 5 && exception is IllegalStateException
if (shouldRetry) {
log("runningEmulators: retrying $exception.")
log("connectedAdbDevices: retrying $exception.")
}

shouldRetry
Expand Down
14 changes: 8 additions & 6 deletions os/src/main/kotlin/com/gojuno/commander/os/Processes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ fun process(
val process: Process = ProcessBuilder(command)
.redirectErrorStream(true)
.let {
when (unbufferedOutput) {
true -> it.redirectOutput(os().nullDeviceFile())
when {
unbufferedOutput && os() !== Windows -> {
it.redirectOutput(os().nullDeviceFile())
}
else -> it.redirectOutput(ProcessBuilder.Redirect.to(outputFile))
}
}
Expand Down Expand Up @@ -127,12 +129,12 @@ enum class Os {
internal fun os(): Os {
val os = System.getProperty("os.name", "unknown").toLowerCase(Locale.ENGLISH)

if (os.contains("mac") || os.contains("darwin")) {
return Mac
return if (os.contains("mac") || os.contains("darwin")) {
Mac
} else if (os.contains("linux")) {
return Linux
Linux
} else if (os.contains("windows")) {
return Windows
Windows
} else {
throw IllegalStateException("Unsupported os $os, only ${Os.values()} are supported.")
}
Expand Down

0 comments on commit 3bc85a0

Please sign in to comment.