@@ -10,7 +10,7 @@ const stackFramesRegexp = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?
1010const windowNewlineRegexp = / \r / g;
1111
1212function replaceNodeVersion ( str ) {
13- return str . replaceAll ( process . version , '* ' ) ;
13+ return str . replaceAll ( process . version , '<node-version> ' ) ;
1414}
1515
1616function replaceStackTrace ( str , replacement = '$1*$7$8\n' ) {
@@ -31,6 +31,20 @@ function replaceWindowsPaths(str) {
3131 return common . isWindows ? str . replaceAll ( path . win32 . sep , path . posix . sep ) : str ;
3232}
3333
34+ function replaceTrailingSpaces ( str ) {
35+ return str . replaceAll ( / [ \t ] + \n / g, '\n' ) ;
36+ }
37+
38+ // Replaces customized or platform specific executable names to be `node`.
39+ function generalizeExeName ( str ) {
40+ const baseName = path . basename ( process . argv0 || 'node' , '.exe' ) ;
41+ return str . replaceAll ( `${ baseName } --` , 'node --' ) ;
42+ }
43+
44+ function replaceWarningPid ( str ) {
45+ return str . replaceAll ( / \( n o d e : \d + \) / g, '(node:<pid>)' ) ;
46+ }
47+
3448function transformProjectRoot ( replacement = '' ) {
3549 const projectRoot = path . resolve ( __dirname , '../..' ) ;
3650 return ( str ) => {
@@ -152,32 +166,41 @@ function pickTestFileFromLcov(str) {
152166 ) ;
153167}
154168
155- const defaultTransform = transform (
169+ // Transforms basic patterns like:
170+ // - platform specific path and line endings,
171+ // - line trailing spaces,
172+ // - executable specific path and versions.
173+ const basicTransform = transform (
156174 replaceWindowsLineEndings ,
157- replaceStackTrace ,
175+ replaceTrailingSpaces ,
158176 removeWindowsPathEscaping ,
159- transformProjectRoot ( ) ,
160177 replaceWindowsPaths ,
178+ replaceNodeVersion ,
179+ generalizeExeName ,
180+ replaceWarningPid ,
181+ ) ;
182+
183+ const defaultTransform = transform (
184+ basicTransform ,
185+ replaceStackTrace ,
186+ transformProjectRoot ( ) ,
161187 replaceTestDuration ,
162188 replaceTestLocationLine ,
163189) ;
164190const specTransform = transform (
165191 replaceSpecDuration ,
166- replaceWindowsLineEndings ,
192+ basicTransform ,
167193 replaceStackTrace ,
168- replaceWindowsPaths ,
169194) ;
170195const junitTransform = transform (
171196 replaceJunitDuration ,
172- replaceWindowsLineEndings ,
197+ basicTransform ,
173198 replaceStackTrace ,
174- replaceWindowsPaths ,
175199) ;
176200const lcovTransform = transform (
177- replaceWindowsLineEndings ,
201+ basicTransform ,
178202 replaceStackTrace ,
179203 transformProjectRoot ( ) ,
180- replaceWindowsPaths ,
181204 pickTestFileFromLcov ,
182205) ;
183206
@@ -204,6 +227,7 @@ module.exports = {
204227 transform,
205228 transformProjectRoot,
206229 replaceTestDuration,
230+ basicTransform,
207231 defaultTransform,
208232 specTransform,
209233 junitTransform,
0 commit comments