@@ -23,6 +23,11 @@ const cleanup = (cwd: string) => {
2323 )
2424}
2525
26+ // Convert path to use forward slashes and normalize it
27+ const normalizePath = ( str : string ) => {
28+ return str . replace ( / \\ + / g, '/' ) // Convert backslashes to forward slashes
29+ }
30+
2631examples . forEach ( ex => {
2732 test ( `example ${ ex } ` , async ( ) => {
2833 const dir = path . join ( examplesDir , ex )
@@ -32,6 +37,9 @@ examples.forEach(ex => {
3237
3338 cleanup ( dir )
3439
40+ const cwd = path . resolve ( process . cwd ( ) ) // Get absolute path
41+ const normalizedCwd = normalizePath ( cwd ) // Normalize cwd path
42+
3543 const stdout = bash
3644 . split ( '\n' )
3745 . map ( line => line . split ( '#' ) [ 0 ] . trim ( ) )
@@ -41,7 +49,8 @@ examples.forEach(ex => {
4149 let output = execa . sync ( 'sh' , [ '-c' , `${ cmd } 2>&1` ] , { cwd : dir } ) . stdout
4250 output = stripAnsi ( output )
4351 output = cmd . startsWith ( 'npm' ) || cmd . endsWith ( '--help' ) ? '...' : output // npm commands and `--help` are formatted inconsistently and aren't v relevant
44- output = output . split ( process . cwd ( ) ) . join ( '<<cwd>>' ) // cwd varies by machine
52+ output = normalizePath ( output )
53+ output = output . split ( normalizedCwd ) . join ( '<<cwd>>' ) // cwd varies by machine
4554 output = output . replaceAll ( / d u r a t i o n S e c o n d s : .* / g, 'durationSeconds: ???' ) // migrations durations vary by a few milliseconds
4655 output = output . replaceAll ( / \d { 4 } .\d { 2 } .\d { 2 } T \d { 2 } .\d { 2 } .\d { 2 } / g, '<<timestamp>>' ) // the river of time flows only in one direction
4756 return [ `\`${ cmd } \` output:` , output ]
0 commit comments