feat(run): colour the console of a Spring Boot run (#781)

Spring Boot configurations get -Dspring.output.ansi.enabled=always: the Run console renders ANSI colours, but Spring only enables them for a terminal and the process runs on pipes. A configuration that sets the property keeps its value.

Co-authored-by: ntbang0901 <[email protected]>
Цей коміт міститься в:
ntbang0901 authored and GitHub committed 2026-11-02 14:57:07 +08:00
1 джерело 95188d9f40
коміт 193e6a4840
2 files changed
+27 -1

No files matched your search

+15
Переглянути файл
@@ -252,6 +252,21 @@ describe("java command lines", () => {
).toEqual(["--module-path", "/m/x.jar"]);
});
it("colours a Spring Boot console unless the configuration sets the property", () => {
const boot = (args: string[]) => ({
...applicationConfig({ className: "a.Main" }, "src/main/java/a/Main.java"),
kind: "spring-boot" as const,
args,
});
expect(resolveJavaCommand(boot(["-Xmx1g", "a.Main"]), info).args[0]).toBe("-Dspring.output.ansi.enabled=always");
expect(resolveJavaCommand(boot(["-Dspring.output.ansi.enabled=never", "a.Main"]), info).args).toEqual([
"-Dspring.output.ansi.enabled=never",
"a.Main",
]);
const plain = applicationConfig({ className: "a.Main" }, "src/main/java/a/Main.java");
expect(resolveJavaCommand(plain, info).args).not.toContain("-Dspring.output.ansi.enabled=always");
});
it("joins arguments for java-debug and reads JDWP's port", () => {
expect(joinJavaArgs(["a", "b c", 'q"'])).toBe('a "b c" "q\\""');
expect(jdwpListeningPort("Listening for transport dt_socket at address: 50123")).toBe(50123);