@@ -10,6 +10,9 @@ const { hostname } = require('node:os');
1010const stackFramesRegexp = / (?< = \n ) ( \s + ) ( ( .+ ?) \s + \( ) ? (?: \( ? ( .+ ?) : ( \d + ) (?: : ( \d + ) ) ? ) \) ? ( \s + \{ ) ? ( \[ \d + m ) ? ( \n | $ ) / g;
1111const windowNewlineRegexp = / \r / g;
1212
13+ // Replaces the current Node.js executable version strings with a
14+ // placeholder. This could commonly present in an unhandled exception
15+ // output.
1316function replaceNodeVersion ( str ) {
1417 return str . replaceAll ( process . version , '<node-version>' ) ;
1518}
@@ -24,29 +27,38 @@ function replaceInternalStackTrace(str) {
2427 return str . replaceAll ( / ( \W + ) .* [ ( \s ] n o d e : .* / g, '$1*' ) ;
2528}
2629
30+ // Replaces Windows line endings with posix line endings for unified snapshots
31+ // across platforms.
2732function replaceWindowsLineEndings ( str ) {
2833 return str . replace ( windowNewlineRegexp , '' ) ;
2934}
3035
36+ // Replaces all Windows path separators with posix separators for unified snapshots
37+ // across platforms.
3138function replaceWindowsPaths ( str ) {
3239 return common . isWindows ? str . replaceAll ( path . win32 . sep , path . posix . sep ) : str ;
3340}
3441
42+ // Removes line trailing white spaces.
3543function replaceTrailingSpaces ( str ) {
3644 return str . replaceAll ( / [ \t ] + \n / g, '\n' ) ;
3745}
3846
39- // Replaces customized or platform specific executable names to be `node`.
47+ // Replaces customized or platform specific executable names to be `< node-exe> `.
4048function generalizeExeName ( str ) {
4149 const baseName = path . basename ( process . argv0 || 'node' , '.exe' ) ;
42- return str . replaceAll ( `${ baseName } --` , 'node --' ) ;
50+ return str . replaceAll ( `${ baseName } --` , '< node-exe> --' ) ;
4351}
4452
53+ // Replaces the pids in warning messages with a placeholder.
4554function replaceWarningPid ( str ) {
4655 return str . replaceAll ( / \( n o d e : \d + \) / g, '(node:<pid>)' ) ;
4756}
4857
49- function transformProjectRoot ( replacement = '' ) {
58+ // Replaces path strings representing the nodejs/node repo full project root with
59+ // `<project-root>`. Also replaces file URLs containing the full project root path.
60+ // The project root path may contain unicode characters.
61+ function transformProjectRoot ( replacement = '<project-root>' ) {
5062 const projectRoot = path . resolve ( __dirname , '../..' ) ;
5163 // Handles URL encoded project root in file URL strings as well.
5264 const urlEncoded = pathToFileURL ( projectRoot ) . pathname ;
0 commit comments