Skip to content

Commit 67df768

Browse files
committed
Fix - remove ansi colors from output of scala-cli.
1 parent 21e1cf4 commit 67df768

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

modules/docs-tests/src/main/scala/sclicheck/sclicheck.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ def mkBashScript(content: Seq[String]) =
139139
|${content.mkString("\n")}
140140
|""".stripMargin
141141

142+
def removeAnsiColors(str: String) = str.replaceAll("\\e\\[[0-9]+m", "")
143+
142144
private lazy val baseTmpDir = {
143145
val random = new SecureRandom
144146
val dirName = s"run-${math.abs(random.nextInt.toLong)}"
@@ -251,7 +253,7 @@ def checkFile(file: os.Path, options: Options): Unit =
251253

252254
case Commands.Check(patterns, regex, line) =>
253255
check(lastOutput != null, "No output stored from previous commands")
254-
val lines = lastOutput.linesIterator.toList
256+
val lines = lastOutput.linesIterator.toList.map(removeAnsiColors)
255257

256258
if regex then
257259
patterns.foreach { pattern =>

0 commit comments

Comments
 (0)