mirror of
https://github.com/apple/pkl.git
synced 2026-06-27 07:46:19 +02:00
Add colours to Pkl errors in Cli output
To make error messages from Pkl eval easier to read, this change uses the Jansi library to colour the output, making it quicker and easier to scan error messages and understand what's happened. The Jansi library also detects if the CLI output is a terminal capable of handling colours, and will automatically strip out escape codes if the output won't support them (e.g. piping the output somewhere else).
This commit is contained in:
committed by
Philip K.F. Hölzenspies
parent
49aaf288cc
commit
0d7b95d3ff
@@ -3,7 +3,6 @@ package org.pkl.core
|
||||
import org.pkl.commons.createTempFile
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import org.pkl.commons.writeString
|
||||
@@ -11,7 +10,6 @@ import org.pkl.core.ModuleSource.*
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.createFile
|
||||
import kotlin.io.path.name
|
||||
|
||||
class EvaluateTestsTest {
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ class EvaluatorTest {
|
||||
val evaluatorBuilder = EvaluatorBuilder.preconfigured().setModuleCacheDir(cacheDir)
|
||||
val project = Project.load(modulePath("/org/pkl/core/project/project6/PklProject"))
|
||||
evaluatorBuilder.setProjectDependencies(project.dependencies).build().use { evaluator ->
|
||||
assertThatCode {
|
||||
assertThatCode {
|
||||
evaluator.evaluateOutputText(modulePath("/org/pkl/core/project/project6/globWithinDependency.pkl"))
|
||||
}.hasMessageContaining("""
|
||||
Cannot resolve import in local dependency because scheme `modulepath` is not globbable.
|
||||
|
||||
@@ -149,8 +149,9 @@ class ProjectTest {
|
||||
.setModuleCacheDir(null)
|
||||
.setHttpClient(httpClient)
|
||||
.build()
|
||||
assertThatCode { evaluator.evaluate(ModuleSource.path(projectDir.resolve("bug.pkl"))) }
|
||||
.hasMessageStartingWith("""
|
||||
assertThatCode {
|
||||
evaluator.evaluate(ModuleSource.path(projectDir.resolve("bug.pkl")))
|
||||
}.hasMessageStartingWith("""
|
||||
–– Pkl Error ––
|
||||
Cannot download package `package://localhost:0/fruit@1.0.5` because the computed checksum for package metadata does not match the expected checksum.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user