Skip to content

Commit afc6ede

Browse files
authored
fix: display build errors to users during reload (#1222)
1 parent d28a160 commit afc6ede

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

sbt-runner/src/main/scala/org/scastie/sbt/OutputExtractor.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class OutputExtractor(getScalaJsContent: () => Option[String],
4646

4747
val isScalaJs = inputs.target.targetType == ScalaTargetType.JS
4848

49+
val isSbtError = output.line.startsWith("[error]") && isReloading
50+
4951
val userOutput =
5052
if (problems.toList.flatten.isEmpty
5153
&& instrumentations.toList.flatten.isEmpty
@@ -55,6 +57,8 @@ class OutputExtractor(getScalaJsContent: () => Option[String],
5557
&& !isReloading
5658
&& consoleOutput.isEmpty)
5759
Some(output)
60+
else if (isSbtError)
61+
Some(output)
5862
else None
5963

6064
val (scalaJsContent, scalaJsSourceMapContent) =
@@ -64,9 +68,7 @@ class OutputExtractor(getScalaJsContent: () => Option[String],
6468
(None, None)
6569
}
6670

67-
val isSbtError = output.line.startsWith("[error]") && isReloading
68-
69-
val isReallyDone = (isDone && !isReloading) || isSbtError
71+
val isReallyDone = isDone && !isReloading
7072

7173
val sbtProcessOutput =
7274
consoleOutput match {

sbt-runner/src/main/scala/org/scastie/sbt/SbtProcess.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,11 @@ class SbtProcess(runTimeout: FiniteDuration,
236236
sendProgress(sbtRun, progress)
237237

238238
if (progress.isSbtError) {
239+
sbtRun.timeoutEvent.foreach(_.cancel())
240+
val finalProgress = progress.copy(isDone = true)
241+
sendProgress(sbtRun, finalProgress)
239242
throw new Exception("sbt error: " + output.line)
240-
}
241-
242-
if (isPrompt(output.line)) {
243+
} else if (isPrompt(output.line)) {
243244
gotoRunning(sbtRun)
244245
} else {
245246
stay()

0 commit comments

Comments
 (0)