🔧 Update color rendering logic and upgrade script dependencies

This commit is contained in:
2026-04-11 08:53:13 +08:00
parent dc11b5c0ff
commit a315d9778d
3 changed files with 17 additions and 17 deletions

View File

@@ -414,7 +414,7 @@ interface ColorToken {
color?: string;
}
function parseColorTokens(message: string, renderColor: boolean): ColorToken[] {
function parseColorTokens(message: string): ColorToken[] {
const tokens: ColorToken[] = [];
if (message) {
let inColorStart = false;
@@ -588,11 +588,11 @@ function __getColorCode(color: string): string {
return COLOR_MAP[color];
}
function renderColorTokens(tokens: ColorToken[]): string {
function renderColorTokens(tokens: ColorToken[], renderColor: bool): string {
const text: string[] = [];
const colorMapStack = new Map<string, number[]>();
for (const token of tokens) {
if (token.type === "color") {
if (token.type === "color" && renderColor) {
const color = token.color;
if (color) {
const colorCode = __getColorCode(color);
@@ -629,7 +629,7 @@ function renderColorTokens(tokens: ColorToken[]): string {
}
}
}
text.push("\x1b[0m"); // FINALLY END ALL COLOR
renderColor && text.push("\x1b[0m"); // FINALLY END ALL COLOR
return text.join("");
}