replace the homemade clearAnsiEscapes with the native stripVTControlCharacters (#13117)
This commit is contained in:
parent
e2dcbad153
commit
f6d93d1151
1 changed files with 2 additions and 6 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { stripVTControlCharacters } from 'node:util'
|
||||
import pc from 'picocolors'
|
||||
import { resolve } from '../utils/resolve'
|
||||
import { formatNanoseconds } from './format-ns'
|
||||
|
|
@ -48,7 +49,7 @@ export function wordWrap(text: string, width: number) {
|
|||
let line = ''
|
||||
let lineLength = 0
|
||||
for (let word of words) {
|
||||
let wordLength = clearAnsiEscapes(word).length
|
||||
let wordLength = stripVTControlCharacters(word).length
|
||||
|
||||
if (lineLength + wordLength + 1 > width) {
|
||||
lines.push(line)
|
||||
|
|
@ -67,11 +68,6 @@ export function wordWrap(text: string, width: number) {
|
|||
return lines
|
||||
}
|
||||
|
||||
const ESCAPE = /((?:\x9B|\x1B\[)[0-?]*[ -\/]*[@-~])/g
|
||||
function clearAnsiEscapes(input: string) {
|
||||
return input.replace(ESCAPE, '')
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a duration in nanoseconds to a more human readable format.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue