@@ -4,14 +4,68 @@ process.env.AWS_ACCESS_KEY_ID = 'blah'
44process . env . AWS_SECRET_ACCESS_KEY = 'blah'
55
66const { spawn } = require ( 'child_process' )
7+ const { readdirSync, statSync } = require ( 'fs' )
8+ const { join } = require ( 'path' )
79const args = process . argv . slice ( 2 )
810
9- // On Windows, we need to use shell to expand globs
10- const isWindows = process . platform === 'win32'
11+ // Simple glob expansion for **/*-test.js pattern
12+ function expandGlob ( pattern ) {
13+ if ( ! pattern . includes ( '*' ) ) {
14+ return [ pattern ]
15+ }
1116
12- const child = spawn ( 'node' , args , {
17+ // Handle test/unit/**/*-test.js pattern
18+ const match = pattern . match ( / ^ ( .+ ?) \/ \* \* \/ \* ( .+ ) $ / )
19+ if ( match ) {
20+ const baseDir = match [ 1 ]
21+ const suffix = match [ 2 ]
22+ const files = [ ]
23+
24+ function walk ( dir ) {
25+ try {
26+ const entries = readdirSync ( dir )
27+ for ( const entry of entries ) {
28+ const fullPath = join ( dir , entry )
29+ try {
30+ const stat = statSync ( fullPath )
31+ if ( stat . isDirectory ( ) ) {
32+ walk ( fullPath )
33+ }
34+ else if ( entry . endsWith ( suffix ) ) {
35+ files . push ( fullPath )
36+ }
37+ }
38+ catch {
39+ // Skip files we can't stat
40+ }
41+ }
42+ }
43+ catch {
44+ // Skip directories we can't read
45+ }
46+ }
47+
48+ walk ( baseDir )
49+ return files
50+ }
51+
52+ return [ pattern ]
53+ }
54+
55+ // Expand any glob patterns in args
56+ const expandedArgs = [ ]
57+ for ( const arg of args ) {
58+ if ( arg . includes ( '*' ) ) {
59+ expandedArgs . push ( ...expandGlob ( arg ) )
60+ }
61+ else {
62+ expandedArgs . push ( arg )
63+ }
64+ }
65+
66+ const child = spawn ( 'node' , expandedArgs , {
1367 stdio : 'inherit' ,
14- shell : isWindows ,
68+ shell : false ,
1569} )
1670
1771child . on ( 'exit' , ( code ) => {
0 commit comments