🔧 Update color rendering logic and upgrade script dependencies
This commit is contained in:
@@ -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("");
|
||||
}
|
||||
|
||||
|
||||
@@ -322,12 +322,12 @@
|
||||
},
|
||||
"tree.ts": {
|
||||
"script_name": "tree.ts",
|
||||
"script_length": 2773,
|
||||
"script_sha256": "269af8218f226dd722ebce67eaa7acfc83cec4400bf1c047ebb0cbddc364ab58",
|
||||
"script_length": 2855,
|
||||
"script_sha256": "7df6c0ead4d18499c3318eb5e7b638ef535b6a05930a3ae13f1a4e554d9e9dc7",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/tree.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1769361581018,
|
||||
"update_time": 1769705771521
|
||||
"update_time": 1775868785446
|
||||
},
|
||||
"trim.ts": {
|
||||
"script_name": "trim.ts",
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
log,
|
||||
parseIntVal,
|
||||
term,
|
||||
} from "https://global.hatter.ink/script/get/@21/deno-commons-mod.ts";
|
||||
} from "https://global.hatter.ink/script/get/@70/deno-commons-mod.ts";
|
||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||
|
||||
const defaultSkipDirs = [
|
||||
@@ -35,7 +35,7 @@ async function listDir(
|
||||
const showNextDepth = (depth + 1) <= maxDepth;
|
||||
console.log(
|
||||
`${tab}- [${dirEntry.name}]${
|
||||
showNextDepth ? "" : term.blue(" \t[...more dirs...]")
|
||||
showNextDepth ? "" : term.auto("[blue][[[ \t[...more dirs...]]]][/]")
|
||||
}`,
|
||||
);
|
||||
if (showNextDepth) {
|
||||
@@ -48,22 +48,22 @@ async function listDir(
|
||||
} else if (dirEntry.isFile) {
|
||||
const fileInfo = await Deno.stat(fullName);
|
||||
if (fileInfo.size > 1024 * 1024) {
|
||||
fileDesc = term.red(
|
||||
` - ${formatSize2(fileInfo.size)}`,
|
||||
fileDesc = term.auto(
|
||||
`[red][[[ - ${formatSize2(fileInfo.size)}]]]][/]`,
|
||||
);
|
||||
} else {
|
||||
fileDesc = term.yellow(
|
||||
` - ${formatSize2(fileInfo.size)}`,
|
||||
fileDesc = term.auto(
|
||||
`[yellow][[[ - ${formatSize2(fileInfo.size)}]]][/]`,
|
||||
);
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
`${tab}- ${term.green(dirEntry.name)} \t${fileDesc}`,
|
||||
`${tab}- ${term.auto("[green][[["+dirEntry.name+"]]][/]")} \t${fileDesc}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(term.red(`${tab} ERROR: ${e}`));
|
||||
console.log(term.auto(`[red][[[${tab} ERROR: ${e}]]][/]`));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,5 +93,5 @@ tree.ts [parameters] <dir>
|
||||
|
||||
main().catch((e) => log.error(e));
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260130T005327+08:00.MEUCICFLf8ZlGN4bSzCiRBlW
|
||||
// AnPVvd4by4hrwq6ZZPaN/cY6AiEAtyx0B6/EINNU2ilPoY1g0+LGc5FylLEJ5Ybn+pkpn8I=
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260411T085252+08:00.MEQCIF2mljiVKgw/oBHggTcd
|
||||
// bIyoWblVNdk8NxsEqMsxUqFMAiBVZKjn/XaZOPwpluv8wOlRtl/FqZZ3fmPj3YgGjVNjsg==
|
||||
|
||||
Reference in New Issue
Block a user