Merge pull request #6067 from eatkins/sbt-ci

Fix console with -Dsbt.ci=true
This commit is contained in:
eugene yokota 2020-11-06 17:40:19 -05:00 committed by GitHub
commit e3131a8205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 12 deletions

View File

@ -334,11 +334,11 @@ object Terminal {
* @tparam T the result type of the thunk
* @return the result of the thunk
*/
private[sbt] def withStreams[T](isServer: Boolean)(f: => T): T =
private[sbt] def withStreams[T](isServer: Boolean)(f: => T): T = {
// In ci environments, don't touch the io streams unless run with -Dsbt.io.virtual=true
if (hasConsole && !isDumbTerminal) consoleTerminalHolder.set(newConsoleTerminal())
if (System.getProperty("sbt.io.virtual", "") == "true" || !isCI) {
hasProgress.set(isServer && isAnsiSupported)
if (hasConsole && !isDumbTerminal) consoleTerminalHolder.set(newConsoleTerminal())
activeTerminal.set(consoleTerminalHolder.get)
try withOut(withIn(f))
finally {
@ -372,6 +372,7 @@ object Terminal {
}
}
} else f
}
private[this] object ProxyTerminal extends Terminal {
private def t: Terminal = activeTerminal.get
@ -1006,17 +1007,8 @@ object Terminal {
}
private[sbt] object NullTerminal extends DefaultTerminal
private[sbt] object SimpleTerminal extends DefaultTerminal {
override lazy val inputStream: InputStream =
if (isCI) BlockingInputStream
else originalIn
override lazy val inputStream: InputStream = originalIn
override lazy val outputStream: OutputStream = originalOut
override lazy val errorStream: OutputStream = originalErr
}
private[this] object BlockingInputStream extends SimpleInputStream {
override def read(): Int = {
try this.synchronized(this.wait)
catch { case _: InterruptedException => }
-1
}
}
}