Skip to content

Commit 3d2b21c

Browse files
authored
Merge pull request #230 from olafurpg/moped-no-color
Tweak ANSI color output
2 parents 99b6f0b + eb6cdbb commit 3d2b21c

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ lazy val V =
1111
val coursier = "2.0.8"
1212
val bloop = "1.4.7"
1313
val bsp = "2.0.0-M13"
14-
val moped = "0.1.9"
14+
val moped = "0.1.10"
1515
def scala213 = "2.13.4"
1616
def scala212 = "2.12.12"
1717
def scalameta = "4.4.8"

lsif-java/src/main/scala/com/sourcegraph/lsif_java/buildtools/GradleBuildTool.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
7575
buildCommand ++= index.finalBuildCommand(List("clean", "compileTestJava"))
7676
buildCommand += lsifJavaDependencies
7777

78-
val result = index.process(buildCommand)
78+
val result = index.process(buildCommand, env = Map("TERM" -> "dumb"))
7979
printDebugLogs(toolchains.tmp)
8080
Embedded
8181
.reportUnexpectedJavacErrors(index.app.reporter, toolchains.tmp)

lsif-java/src/main/scala/com/sourcegraph/lsif_java/buildtools/MavenBuildTool.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class MavenBuildTool(index: IndexCommand) extends BuildTool("Maven", index) {
4545
buildCommand ++=
4646
index.finalBuildCommand(
4747
List(
48+
s"--batch-mode",
4849
s"clean",
4950
// Default to the "verify" command, as recommended by the official docs
5051
// https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#usual-command-line-calls

lsif-java/src/main/scala/com/sourcegraph/lsif_java/commands/IndexCommand.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import java.nio.file.Paths
66

77
import com.sourcegraph.io.AbsolutePath
88
import com.sourcegraph.lsif_java.buildtools.BuildTool
9+
import fansi.Color
910
import moped.annotations._
1011
import moped.cli.Application
1112
import moped.cli.Command
1213
import moped.cli.CommandParser
1314
import moped.internal.reporters.Levenshtein
1415
import os.CommandResult
15-
import os.Inherit
16+
import os.ProcessOutput
1617
import os.Shellable
1718

1819
@Description(
@@ -65,13 +66,13 @@ case class IndexCommand(
6566
shellable: Shellable,
6667
env: Map[String, String] = Map.empty
6768
): CommandResult = {
68-
app.info(shellable.value.mkString(" "))
69+
app.out.println(Color.DarkGray(shellable.value.mkString("$ ", " ", "")))
6970
app
7071
.process(shellable)
7172
.call(
7273
check = false,
73-
stdout = Inherit,
74-
stderr = Inherit,
74+
stdout = ProcessOutput.Readlines(line => app.out.println(line)),
75+
stderr = ProcessOutput.Readlines(line => app.err.println(line)),
7576
cwd = workingDirectory,
7677
env = env
7778
)

tests/buildTools/src/test/scala/tests/BaseBuildToolSuite.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class BaseBuildToolSuite extends MopedSuite(LsifJava.app) {
3737
original: String,
3838
expectedSemanticdbFiles: Int = 0,
3939
extraArguments: List[String] = Nil,
40-
expectedError: String = "",
40+
expectedError: Option[String => Unit] = None,
4141
expectedPackages: String = "",
4242
initCommand: => List[String] = Nil
4343
): Unit = {
@@ -59,11 +59,12 @@ abstract class BaseBuildToolSuite extends MopedSuite(LsifJava.app) {
5959
if (extraArguments.contains("--verbose")) {
6060
println(app.capturedOutput)
6161
}
62-
if (expectedError.nonEmpty) {
63-
assert(clue(exit) != 0, clues(app.capturedOutput))
64-
assertNoDiff(app.capturedOutput, expectedError)
65-
} else {
66-
assertEquals(exit, 0, clues(app.capturedOutput))
62+
expectedError match {
63+
case Some(fn) =>
64+
assert(clue(exit) != 0, clues(app.capturedOutput))
65+
fn(app.capturedOutput)
66+
case None =>
67+
assertEquals(exit, 0, clues(app.capturedOutput))
6768
}
6869
val semanticdbFiles =
6970
if (!Files.isDirectory(targetroot))

tests/buildTools/src/test/scala/tests/GradleBuildToolSuite.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ class GradleBuildToolSuite extends BaseBuildToolSuite {
103103
|/src/main/java/Example.java
104104
|public class Example {}
105105
|""".stripMargin,
106-
expectedError =
107-
"""|info: /workingDirectory/gradlew --init-script /cache/java-toolchains.gradle lsifDetectJavaToolchains
108-
|error: lsif-java does not support Gradle 6.7 when used together with Java toolchains. To fix this problem, upgrade to Gradle version 6.8 or newer and try again.
109-
|""".stripMargin,
106+
expectedError = Some { error =>
107+
assert(
108+
clue(error).contains(
109+
"""error: lsif-java does not support Gradle 6.7 when used together with Java toolchains. To fix this problem, upgrade to Gradle version 6.8 or newer and try again."""
110+
)
111+
)
112+
},
110113
initCommand = gradleVersion("6.7")
111114
)
112115

0 commit comments

Comments
 (0)