дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 11:15:40 +02:00
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]>
Цей коміт міститься в:
1 джерело
95188d9f40
коміт
193e6a4840
2 files changed
+27
-1
No files matched your search
@@ -71,10 +71,21 @@ export function parseJavaArgs(args: readonly string[]): JavaCommandLine {
|
||||
return { vmArgs, mainClass: null, programArgs: [], classpath, explicitClasspath };
|
||||
}
|
||||
|
||||
/**
|
||||
* VM options a launch adds for the console, as IDEA's Spring Boot configurations do: the
|
||||
* console renders ANSI colours, but Spring only detects a terminal, and the process runs on pipes.
|
||||
* Kept out when the configuration sets the property itself.
|
||||
*/
|
||||
export function consoleVmArgs(config: Pick<RunConfig, "kind" | "args">): string[] {
|
||||
if (config.kind !== "spring-boot") return [];
|
||||
const own = parseJavaArgs(config.args).vmArgs.some((a) => a.startsWith("-Dspring.output.ansi.enabled="));
|
||||
return own ? [] : ["-Dspring.output.ansi.enabled=always"];
|
||||
}
|
||||
|
||||
/** The configuration with its placeholders and launcher resolved. */
|
||||
export function resolveJavaCommand(config: RunConfig, info: JavaLaunchInfo): RunConfig {
|
||||
const cp = info.classPaths.join(info.pathListSeparator);
|
||||
const args: string[] = [];
|
||||
const args: string[] = [...consoleVmArgs(config)];
|
||||
if (info.modulePaths.length && !config.args.some((a) => a === "-p" || a === "--module-path"))
|
||||
args.push("--module-path", info.modulePaths.join(info.pathListSeparator));
|
||||
args.push(...config.args.map((a) => (a === CLASSPATH || a === TEST_CLASSPATH ? cp : a)));
|
||||
|
||||
Reference in new issue
Заблокувати користувача