Skip to content

Commit

Permalink
correct severity
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Khaiminov committed Sep 3, 2024
1 parent 5d49397 commit f6f58d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .idea/GitlabLint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ coroutines = "1.8.1"
junit = "5.11.0"

# Output
kts-compiler = "1.0.1"
kts-compiler = "1.0.2"

[libraries]
kts-jvm-host = { module = "org.jetbrains.kotlin:kotlin-scripting-jvm-host", version.ref = "kotlin" }
Expand Down
9 changes: 7 additions & 2 deletions src/main/kotlin/mx/platacard/kts/KtsCompiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mx.platacard.kts
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.mainKts.MainKtsScript
import java.io.File
import kotlin.script.experimental.api.ScriptDiagnostic.Severity
import kotlin.script.experimental.host.toScriptSource
import kotlin.script.experimental.jvm.util.isError
import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost
Expand All @@ -20,15 +21,19 @@ object KtsCompiler {
return when {
resultWithDiagnostics.isError().not() -> Result.Success
else -> {
val results =
resultWithDiagnostics.reports.filter {
it.severity == Severity.ERROR || it.severity == Severity.FATAL
}
val message =
resultWithDiagnostics.reports.joinToString(separator = "\n") {
results.joinToString(separator = "\n") {
it.render(
withStackTrace = true,
)
}
Result.Failure(
formattedMessage = message,
errors = resultWithDiagnostics.reports.mapNotNull { it.exception },
errors = results.mapNotNull { it.exception },
)
}
}
Expand Down

0 comments on commit f6f58d3

Please sign in to comment.