Disable ANSI when gradle's --console plain arg is used Fixes #486

dev/0.11
modmuss50 2021-09-07 12:24:57 +01:00
parent 8da2da8aed
commit aaf8653bee
1 changed files with 7 additions and 3 deletions

View File

@ -40,6 +40,7 @@ import java.util.stream.Collectors;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.logging.configuration.ConsoleOutput;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import net.fabricmc.loom.configuration.DependencyProvider; import net.fabricmc.loom.configuration.DependencyProvider;
@ -66,10 +67,13 @@ public class LaunchProvider extends DependencyProvider {
.argument("client", "--assetsDir") .argument("client", "--assetsDir")
.argument("client", new File(getDirectories().getUserCache(), "assets").getAbsolutePath()); .argument("client", new File(getDirectories().getUserCache(), "assets").getAbsolutePath());
//Enable ansi by default for idea and vscode final boolean plainConsole = getProject().getGradle().getStartParameter().getConsoleOutput() == ConsoleOutput.Plain;
if (new File(getProject().getRootDir(), ".vscode").exists() final boolean ansiSupportedIDE = new File(getProject().getRootDir(), ".vscode").exists()
|| new File(getProject().getRootDir(), ".idea").exists() || new File(getProject().getRootDir(), ".idea").exists()
|| (Arrays.stream(getProject().getRootDir().listFiles()).anyMatch(file -> file.getName().endsWith(".iws")))) { || (Arrays.stream(getProject().getRootDir().listFiles()).anyMatch(file -> file.getName().endsWith(".iws")));
//Enable ansi by default for idea and vscode when gradle is not ran with plain console.
if (ansiSupportedIDE && !plainConsole) {
launchConfig.property("fabric.log.disableAnsi", "false"); launchConfig.property("fabric.log.disableAnsi", "false");
} }