Files
ComfyUI_frontend/tools/test-recorder/src/ui/logger.ts
bymyself 7418ce454a fix: address review nitpicks in test-recorder
- Guard box() against empty lines array (RangeError on Math.max)
- Sanitize testName in recording template to prevent injection
2026-04-06 14:36:11 -07:00

44 lines
1.1 KiB
TypeScript

import pc from 'picocolors'
export function pass(label: string, detail?: string) {
const d = detail ? pc.dim(` ${detail}`) : ''
console.log(` ${pc.green('✅')} ${label}${d}`)
}
export function fail(label: string, detail?: string) {
const d = detail ? pc.dim(` ${detail}`) : ''
console.log(` ${pc.red('❌')} ${label}${d}`)
}
export function warn(label: string, detail?: string) {
const d = detail ? pc.dim(` ${detail}`) : ''
console.log(` ${pc.yellow('⚠️')} ${label}${d}`)
}
export function info(lines: string[]) {
for (const line of lines) {
console.log(` ${pc.dim('┃')} ${line}`)
}
}
export function blank() {
console.log()
}
export function header(text: string) {
console.log()
console.log(pc.bold(` ━━━ ${text} ━━━`))
console.log()
}
export function box(lines: string[]) {
if (lines.length === 0) return
const maxLen = Math.max(...lines.map((l) => l.length))
const border = '─'.repeat(maxLen + 4)
console.log(`${border}`)
for (const line of lines) {
console.log(`${line.padEnd(maxLen + 2)}`)
}
console.log(`${border}`)
}