Remove problematic lib chalk

This commit is contained in:
2025-09-06 09:57:22 +02:00
parent 347608ca40
commit 9418bfe6ba
4 changed files with 2 additions and 28 deletions
+1 -5
View File
@@ -7,9 +7,5 @@
"module": "index.ts",
"type": "module",
"files": ["index.ts", "src", "tsconfig.json"],
"dependencies": {
"chalk": "^5.3.0"
}
"files": ["index.ts", "src", "tsconfig.json"]
}
-19
View File
@@ -1,19 +0,0 @@
import {Chalk} from 'chalk'
import {Level} from './types'
const chalk = new Chalk({level: 2}) // 256 colors
export function get_color(level: Level) {
switch (level) {
case Level.DEBUG:
return chalk.blueBright
case Level.TRACE:
return chalk.green
case Level.INFO:
return (str: string) => str
case Level.WARNING:
return chalk.hex('#FFA500')
case Level.ERROR:
return chalk.red
}
}
+1 -3
View File
@@ -1,5 +1,4 @@
import {Level, type Options, type Writer} from './types'
import {get_color} from './color'
export const writers = new Map<string, Writer>()
export let options: Options = {
@@ -52,7 +51,6 @@ function log(message: any[], level: Level, namespace: string): void {
let lvl = get_string(level)
if (!options.pad_level) lvl = lvl.trimEnd()
const head_color = head.replace('$level', get_color(level)(lvl))
const head_bw = head.replace('$level', lvl)
for (const [name, writer] of writers.entries()) {
@@ -61,7 +59,7 @@ function log(message: any[], level: Level, namespace: string): void {
if (options.verbose) console.log(`Writer's level is lower, discard message for ${name}`)
continue
}
writer.log(level, options?.with_color ? head_color : head_bw, ...message)
writer.log(level, head_bw, ...message)
}
}
-1
View File
@@ -19,7 +19,6 @@ export enum Level {
export type WriterOptions = {
minLevel: Level
with_color: boolean
[key: string | number | symbol]: any
}