@@ -23,6 +23,11 @@ const cleanup = (cwd: string) => {
23
23
)
24
24
}
25
25
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
+
26
31
examples . forEach ( ex => {
27
32
test ( `example ${ ex } ` , async ( ) => {
28
33
const dir = path . join ( examplesDir , ex )
@@ -32,6 +37,9 @@ examples.forEach(ex => {
32
37
33
38
cleanup ( dir )
34
39
40
+ const cwd = path . resolve ( process . cwd ( ) ) // Get absolute path
41
+ const normalizedCwd = normalizePath ( cwd ) // Normalize cwd path
42
+
35
43
const stdout = bash
36
44
. split ( '\n' )
37
45
. map ( line => line . split ( '#' ) [ 0 ] . trim ( ) )
@@ -41,7 +49,8 @@ examples.forEach(ex => {
41
49
let output = execa . sync ( 'sh' , [ '-c' , `${ cmd } 2>&1` ] , { cwd : dir } ) . stdout
42
50
output = stripAnsi ( output )
43
51
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
45
54
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
46
55
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
47
56
return [ `\`${ cmd } \` output:` , output ]
0 commit comments