Skip to content

Commit e08a686

Browse files
unity-cli@1.3.2
- fix android sdk license acceptance input
1 parent 4e6a43f commit e08a686

3 files changed

Lines changed: 13 additions & 18 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rage-against-the-pixel/unity-cli",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "A command line utility for the Unity Game Engine.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",

src/android-sdk.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ async function getAndroidSdkPath(rootEditorPath: string, androidTargetSdk: numbe
113113
}
114114

115115
async 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

Comments
 (0)