From e08a6866c593843a2127ee9ca9ef4632d6c24d5f Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Fri, 17 Oct 2025 11:56:29 -0400 Subject: [PATCH] unity-cli@1.3.2 - fix android sdk license acceptance input --- package-lock.json | 4 ++-- package.json | 2 +- src/android-sdk.ts | 25 ++++++++++--------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index bfaa207..2517aa7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.3.1", + "version": "1.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.3.1", + "version": "1.3.2", "license": "MIT", "dependencies": { "@electron/asar": "^4.0.1", diff --git a/package.json b/package.json index db4ead5..69509e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.3.1", + "version": "1.3.2", "description": "A command line utility for the Unity Game Engine.", "author": "RageAgainstThePixel", "license": "MIT", diff --git a/src/android-sdk.ts b/src/android-sdk.ts index c8e4922..8c5c62b 100644 --- a/src/android-sdk.ts +++ b/src/android-sdk.ts @@ -113,7 +113,6 @@ async function getAndroidSdkPath(rootEditorPath: string, androidTargetSdk: numbe } async function execSdkManager(sdkManagerPath: string, javaPath: string, args: string[]): Promise { - const acceptBuffer = Buffer.from(Array(10).fill('y').join('\n'), 'utf8'); let output = ''; let exitCode = 0; @@ -127,7 +126,10 @@ async function execSdkManager(sdkManagerPath: string, javaPath: string, args: st exitCode = await new Promise((resolve, reject) => { const child = spawn(sdkManagerPath, args, { stdio: ['pipe', 'pipe', 'pipe'], - env: { ...process.env, JAVA_HOME: javaPath } + env: { + ...process.env, + JAVA_HOME: process.platform === 'win32' ? `"${javaPath}"` : javaPath + } }); const sigintHandler = () => child.kill('SIGINT'); const sigtermHandler = () => child.kill('SIGTERM'); @@ -142,22 +144,15 @@ async function execSdkManager(sdkManagerPath: string, javaPath: string, args: st process.removeListener('SIGTERM', sigtermHandler); } - child.stdout.on('data', (data: Buffer) => { - const chunk = data.toString(); - output += chunk; - - if (output.includes('Accept? (y/N):')) { - child.stdin?.write(acceptBuffer); - output = ''; - } - - process.stdout.write(chunk); - }); - child.stderr.on('data', (data: Buffer) => { + function handleDataStream(data: Buffer) { const chunk = data.toString(); output += chunk; process.stderr.write(chunk); - }); + } + const acceptBuffer = Buffer.from(Array(10).fill('y').join(os.EOL), 'utf8'); + child.stdin.write(acceptBuffer); + child.stdout.on('data', (data: Buffer) => handleDataStream(data)); + child.stderr.on('data', (data: Buffer) => handleDataStream(data)); child.on('error', (error) => { removeListeners(); reject(error);