@@ -113,7 +113,6 @@ async function getAndroidSdkPath(rootEditorPath: string, androidTargetSdk: numbe
113113}
114114
115115async function execSdkManager ( sdkManagerPath : string , javaPath : string , args : string [ ] ) : Promise < void > {
116- const acceptBuffer = Buffer . from ( Array ( 10 ) . fill ( 'y' ) . join ( '\n' ) , 'utf8' ) ;
117116 let output = '' ;
118117 let exitCode = 0 ;
119118
@@ -127,7 +126,10 @@ async function execSdkManager(sdkManagerPath: string, javaPath: string, args: st
127126 exitCode = await new Promise < number > ( ( resolve , reject ) => {
128127 const child = spawn ( sdkManagerPath , args , {
129128 stdio : [ 'pipe' , 'pipe' , 'pipe' ] ,
130- env : { ...process . env , JAVA_HOME : javaPath }
129+ env : {
130+ ...process . env ,
131+ JAVA_HOME : process . platform === 'win32' ? `"${ javaPath } "` : javaPath
132+ }
131133 } ) ;
132134 const sigintHandler = ( ) => child . kill ( 'SIGINT' ) ;
133135 const sigtermHandler = ( ) => child . kill ( 'SIGTERM' ) ;
@@ -142,22 +144,15 @@ async function execSdkManager(sdkManagerPath: string, javaPath: string, args: st
142144 process . removeListener ( 'SIGTERM' , sigtermHandler ) ;
143145 }
144146
145- child . stdout . on ( 'data' , ( data : Buffer ) => {
146- const chunk = data . toString ( ) ;
147- output += chunk ;
148-
149- if ( output . includes ( 'Accept? (y/N):' ) ) {
150- child . stdin ?. write ( acceptBuffer ) ;
151- output = '' ;
152- }
153-
154- process . stdout . write ( chunk ) ;
155- } ) ;
156- child . stderr . on ( 'data' , ( data : Buffer ) => {
147+ function handleDataStream ( data : Buffer ) {
157148 const chunk = data . toString ( ) ;
158149 output += chunk ;
159150 process . stderr . write ( chunk ) ;
160- } ) ;
151+ }
152+ const acceptBuffer = Buffer . from ( Array ( 10 ) . fill ( 'y' ) . join ( os . EOL ) , 'utf8' ) ;
153+ child . stdin . write ( acceptBuffer ) ;
154+ child . stdout . on ( 'data' , ( data : Buffer ) => handleDataStream ( data ) ) ;
155+ child . stderr . on ( 'data' , ( data : Buffer ) => handleDataStream ( data ) ) ;
161156 child . on ( 'error' , ( error ) => {
162157 removeListeners ( ) ;
163158 reject ( error ) ;
0 commit comments