@@ -15,20 +15,32 @@ export const normalizeCodeToPosix = (code: string): string => {
1515 return code . replace (
1616 // windows absolute path
1717 // ignore http, https, file
18- / (?< ! [ a - z A - Z ] ) ( [ a - z A - Z ] : [ \\ / ] + ) ( [ - \u4e00 - \u9fa5 \w \s . ( ) ~ ! @ # $ % ^ & ( ) \ [\] { } + = ] + [ \\ / ] + ) * / g,
18+ / (?< ! [ a - z A - Z ] ) ( [ a - z A - Z ] : [ \\ / ] + ) ( [ - \u4e00 - \u9fa5 \w \s . ( ) ~ ! @ # $ % ^ & ( ) [ \] { } + = ] + [ \\ / ] + ) * / g,
1919 ( match : string , _diskName : string ) => {
2020 return normalizePathToPosix ( match . replace ( / [ \\ ] { 2 , } / g, '\\' ) ) ;
2121 } ,
2222 ) ;
2323} ;
2424
25+ const ANSI_ESCAPE = String . raw `\u001b` ;
26+ const ANSI_BOLD_COLOR_REGEXP = new RegExp (
27+ `${ ANSI_ESCAPE } \\[1m${ ANSI_ESCAPE } \\[([0-9;]*)m` ,
28+ 'g' ,
29+ ) ;
30+ const ANSI_BOLD_REGEXP = new RegExp ( `${ ANSI_ESCAPE } \\[1m` , 'g' ) ;
31+ const ANSI_RESET_REGEXP = new RegExp (
32+ `${ ANSI_ESCAPE } \\[39m${ ANSI_ESCAPE } \\[22m` ,
33+ 'g' ,
34+ ) ;
35+ const ANSI_COLOR_REGEXP = new RegExp ( `${ ANSI_ESCAPE } \\[([0-9;]*)m` , 'g' ) ;
36+
2537export const normalizeCLR = ( str : string ) : string => {
2638 return (
2739 str
28- . replace ( / \u001b \[ 1 m \u001b \[ ( [ 0 - 9 ; ] * ) m / g , '<CLR=$1,BOLD>' )
29- . replace ( / \u001b \[ 1 m / g , '<CLR=BOLD>' )
30- . replace ( / \u001b \[ 3 9 m \u001b \[ 2 2 m / g , '</CLR>' )
31- . replace ( / \u001b \[ ( [ 0 - 9 ; ] * ) m / g , '<CLR=$1>' )
40+ . replace ( ANSI_BOLD_COLOR_REGEXP , '<CLR=$1,BOLD>' )
41+ . replace ( ANSI_BOLD_REGEXP , '<CLR=BOLD>' )
42+ . replace ( ANSI_RESET_REGEXP , '</CLR>' )
43+ . replace ( ANSI_COLOR_REGEXP , '<CLR=$1>' )
3244 // CHANGE: The time unit display in Rspack is second
3345 // CHANGE2: avoid a bad case "./react/assets.svg" -> "./react/assetsXsvg"
3446 // modified based on https://github.com/webpack/webpack/blob/001cab14692eb9a833c6b56709edbab547e291a1/test/StatsTestCases.basictest.js#L199
0 commit comments