@@ -3300,7 +3300,6 @@ async function getAndroidSdkPath(rootEditorPath, androidTargetSdk) {
33003300 return sdkPath;
33013301}
33023302async function execSdkManager(sdkManagerPath, javaPath, args) {
3303- const acceptBuffer = Buffer.from(Array(10).fill('y').join('\n'), 'utf8');
33043303 let output = '';
33053304 let exitCode = 0;
33063305 logger.startGroup(`\x1b[34m${sdkManagerPath} ${args.join(' ')}\x1b[0m`);
@@ -3311,7 +3310,10 @@ async function execSdkManager(sdkManagerPath, javaPath, args) {
33113310 exitCode = await new Promise((resolve, reject) => {
33123311 const child = (0, child_process_1.spawn)(sdkManagerPath, args, {
33133312 stdio: ['pipe', 'pipe', 'pipe'],
3314- env: { ...process.env, JAVA_HOME: javaPath }
3313+ env: {
3314+ ...process.env,
3315+ JAVA_HOME: process.platform === 'win32' ? `"${javaPath}"` : javaPath
3316+ }
33153317 });
33163318 const sigintHandler = () => child.kill('SIGINT');
33173319 const sigtermHandler = () => child.kill('SIGTERM');
@@ -3326,20 +3328,15 @@ async function execSdkManager(sdkManagerPath, javaPath, args) {
33263328 process.removeListener('SIGINT', sigintHandler);
33273329 process.removeListener('SIGTERM', sigtermHandler);
33283330 }
3329- child.stdout.on('data', (data) => {
3330- const chunk = data.toString();
3331- output += chunk;
3332- if (output.includes('Accept? (y/N):')) {
3333- child.stdin?.write(acceptBuffer);
3334- output = '';
3335- }
3336- process.stdout.write(chunk);
3337- });
3338- child.stderr.on('data', (data) => {
3331+ function handleDataStream(data) {
33393332 const chunk = data.toString();
33403333 output += chunk;
33413334 process.stderr.write(chunk);
3342- });
3335+ }
3336+ const acceptBuffer = Buffer.from(Array(10).fill('y').join(os_1.default.EOL), 'utf8');
3337+ child.stdin.write(acceptBuffer);
3338+ child.stdout.on('data', (data) => handleDataStream(data));
3339+ child.stderr.on('data', (data) => handleDataStream(data));
33433340 child.on('error', (error) => {
33443341 removeListeners();
33453342 reject(error);
0 commit comments