@@ -102,7 +102,8 @@ export const run = dual<
102102 InternalCommand . getHelp ( e . command , config )
103103 ) ,
104104 execute ,
105- config
105+ config ,
106+ args
106107 )
107108 )
108109 : Option . none ( )
@@ -115,7 +116,7 @@ export const run = dual<
115116 } )
116117 }
117118 case "BuiltIn" : {
118- return handleBuiltInOption ( self , executable , filteredArgs , directive . option , execute , config ) . pipe (
119+ return handleBuiltInOption ( self , executable , filteredArgs , directive . option , execute , config , args ) . pipe (
119120 Effect . catchSome ( ( e ) =>
120121 InternalValidationError . isValidationError ( e )
121122 ? Option . some ( Effect . zipRight ( printDocs ( e . error ) , Effect . fail ( e ) ) )
@@ -151,7 +152,8 @@ const handleBuiltInOption = <R, E, A>(
151152 args : ReadonlyArray < string > ,
152153 builtIn : BuiltInOptions . BuiltInOptions ,
153154 execute : ( a : A ) => Effect . Effect < void , E , R > ,
154- config : CliConfig . CliConfig
155+ config : CliConfig . CliConfig ,
156+ originalArgs : ReadonlyArray < string >
155157) : Effect . Effect <
156158 void ,
157159 E | ValidationError . ValidationError ,
@@ -161,7 +163,10 @@ const handleBuiltInOption = <R, E, A>(
161163 case "SetLogLevel" : {
162164 console . log ( "\n========== ACTUAL TEST ==========" )
163165 console . log ( "executable:" , executable )
164- console . log ( "Has spaces in paths?" , executable . includes ( "Program Files" ) || executable . includes ( "Program Files (x86)" ) )
166+ console . log (
167+ "Has spaces in paths?" ,
168+ executable . includes ( "Program Files" ) || executable . includes ( "Program Files (x86)" )
169+ )
165170
166171 const nextArgs = executable . split ( / \s + / )
167172 console . log ( "After split:" , nextArgs . length , "elements" )
@@ -176,7 +181,7 @@ const handleBuiltInOption = <R, E, A>(
176181 if ( isLogLevelArg ( args [ i ] ) || isLogLevelArg ( args [ i - 1 ] ) ) {
177182 continue
178183 }
179- nextArgs . push ( args [ i ] )
184+ filteredArgs . push ( args [ i ] )
180185 }
181186
182187 console . log ( "Final nextArgs length:" , nextArgs . length )
@@ -285,10 +290,11 @@ const handleBuiltInOption = <R, E, A>(
285290 active : "yes" ,
286291 inactive : "no"
287292 } ) . pipe ( Effect . flatMap ( ( shouldRunCommand ) => {
288- const finalArgs = pipe (
289- Arr . drop ( args , 1 ) ,
290- Arr . prependAll ( executable . split ( / \s + / ) )
291- )
293+ // Use first 2 elements from originalArgs (runtime + script) to preserve paths with spaces
294+ // This mimics executable.split() behavior but without breaking Windows paths
295+ const baseArgs = Arr . take ( originalArgs , 2 )
296+ const wizardArgs = Arr . drop ( args , 1 )
297+ const finalArgs = Arr . appendAll ( baseArgs , wizardArgs )
292298 return shouldRunCommand
293299 ? Console . log ( ) . pipe ( Effect . zipRight ( run ( self , finalArgs , execute ) ) )
294300 : Effect . void
0 commit comments