@@ -136,7 +136,7 @@ async function run(): Promise<void> {
136136
137137 // Handle --variant=<value> format
138138 if ( flag . startsWith ( '--variant=' ) ) {
139- const value = flag . split ( '=' ) [ 1 ] ;
139+ const value = flag . slice ( '--variant=' . length ) ;
140140 const trimmedValue = value ?. trim ( ) ;
141141 if ( trimmedValue ) {
142142 variantLabel = trimmedValue ;
@@ -224,8 +224,24 @@ async function run(): Promise<void> {
224224 await asyncExec ( `volta run ${ buildCommand } ` , { env, cwd } ) ;
225225
226226 console . log ( `Testing ${ testLabel } ...` ) ;
227- // Pass command and arguments as an array to prevent command injection
228- const testCommand = [ 'volta' , 'run' , ...assertCommand . split ( ' ' ) , ...testFlags ] ;
227+ // Pass command as a string to support shell features (env vars, operators like &&)
228+ // This matches how buildCommand is handled for consistency
229+ // Properly quote test flags to preserve spaces and special characters
230+ const quotedTestFlags = testFlags . map ( flag => {
231+ // If flag contains spaces or special shell characters, quote it
232+ if (
233+ flag . includes ( ' ' ) ||
234+ flag . includes ( '"' ) ||
235+ flag . includes ( "'" ) ||
236+ flag . includes ( '$' ) ||
237+ flag . includes ( '`' )
238+ ) {
239+ // Escape single quotes and wrap in single quotes (safest for shell)
240+ return `'${ flag . replace ( / ' / g, "'\\''" ) } '` ;
241+ }
242+ return flag ;
243+ } ) ;
244+ const testCommand = `volta run ${ assertCommand } ${ quotedTestFlags . length > 0 ? ` ${ quotedTestFlags . join ( ' ' ) } ` : '' } ` ;
229245 await asyncExec ( testCommand , { env, cwd } ) ;
230246
231247 // clean up (although this is tmp, still nice to do)
0 commit comments