Skip to content

Commit 52c8510

Browse files
committed
Mitigate scala-js/scala-js#3206: Send stderr of Node.js to the JSConsole.
This way, at least all JS environments agree on what they do with `console.error()`, which is to merge it with `console.log()` and send everything to the `console: JSConsole` (which is the standard output by default). A deeper fix would allow to separately configure stdout and stderr, but that can only be done in Scala.js 1.x in the context of the redesign of `JSEnv`s scala-js/scala-js#3033.
1 parent 44cd5ab commit 52c8510

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

js-envs/src/main/scala/org/scalajs/jsenv/ExternalJSEnv.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,8 @@ abstract class ExternalJSEnv(
9696
try { sendVMStdin(out) }
9797
finally { out.close() }
9898

99-
// Pipe stdout to console
99+
// Pipe stdout (and stderr which is merged into it) to console
100100
pipeToConsole(vmInst.getInputStream(), console)
101-
102-
// We are probably done (stdin is closed). Report any errors
103-
val errSrc = Source.fromInputStream(vmInst.getErrorStream(), "UTF-8")
104-
try { errSrc.getLines.foreach(err => logger.error(err)) }
105-
finally { errSrc.close }
106101
}
107102

108103
/** Wait for the VM to terminate, verify exit code
@@ -125,6 +120,7 @@ abstract class ExternalJSEnv(
125120

126121
val allArgs = executable +: vmArgs
127122
val pBuilder = new ProcessBuilder(allArgs: _*)
123+
pBuilder.redirectErrorStream(true) // merge stderr into stdout
128124

129125
pBuilder.environment().clear()
130126
for ((name, value) <- vmEnv)

0 commit comments

Comments
 (0)