Merge pull request #6115 from eatkins/thin-client-startup

Fix thin client sbt process startup output
This commit is contained in:
eugene yokota 2020-11-18 18:26:28 -05:00 committed by GitHub
commit 9985cb4b1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -337,9 +337,10 @@ 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, isSubProcess: 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 ((hasConsole && !isDumbTerminal) || isSubProcess)
consoleTerminalHolder.set(newConsoleTerminal())
if (hasVirtualIO) {
hasProgress.set(isServer && isAnsiSupported)
activeTerminal.set(consoleTerminalHolder.get)

View File

@ -1160,7 +1160,7 @@ object NetworkClient {
Runtime.getRuntime.addShutdownHook(hook)
if (Util.isNonCygwinWindows) sbt.internal.util.JLine3.forceWindowsJansi()
val parsed = parseArgs(restOfArgs)
System.exit(Terminal.withStreams(false) {
System.exit(Terminal.withStreams(isServer = false, isSubProcess = false) {
val term = Terminal.console
try client(base, parsed, term.inputStream, System.err, term, useJNI)
catch { case _: AccessDeniedException => 1 } finally {

View File

@ -79,13 +79,13 @@ private[sbt] object xMain {
BspClient.run(dealiasBaseDirectory(configuration))
} else {
bootServerSocket.foreach(l => ITerminal.setBootStreams(l.inputStream, l.outputStream))
ITerminal.withStreams(true) {
val detachStdio = userCommands.exists(_ == BasicCommandStrings.DashDashDetachStdio)
ITerminal.withStreams(true, isSubProcess = detachStdio) {
if (clientModByEnv || userCommands.exists(isClient)) {
val args = userCommands.toList.filterNot(isClient)
NetworkClient.run(dealiasBaseDirectory(configuration), args)
Exit(0)
} else {
val detachStdio = userCommands.exists(_ == BasicCommandStrings.DashDashDetachStdio)
val state0 = StandardMain
.initialState(
dealiasBaseDirectory(configuration),