-
-
Notifications
You must be signed in to change notification settings - Fork 0
unity-cli@1.3.2 #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unity-cli@1.3.2 #30
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -113,7 +113,6 @@ async function getAndroidSdkPath(rootEditorPath: string, androidTargetSdk: numbe | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async function execSdkManager(sdkManagerPath: string, javaPath: string, args: string[]): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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<number>((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)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+152
to
+155
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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)); | |
| // Respond to license prompts only when detected in output | |
| const licensePromptRegex = /Accept\?\s*\(y\/N\):/i; | |
| let stdoutBuffer = ''; | |
| let stderrBuffer = ''; | |
| function checkAndRespond(buffer: string) { | |
| if (licensePromptRegex.test(buffer)) { | |
| child.stdin.write('y' + os.EOL); | |
| } | |
| } | |
| child.stdout.on('data', (data: Buffer) => { | |
| const chunk = data.toString(); | |
| stdoutBuffer += chunk; | |
| handleDataStream(data); | |
| checkAndRespond(stdoutBuffer); | |
| // Keep buffer from growing indefinitely | |
| if (stdoutBuffer.length > 1000) stdoutBuffer = stdoutBuffer.slice(-1000); | |
| }); | |
| child.stderr.on('data', (data: Buffer) => { | |
| const chunk = data.toString(); | |
| stderrBuffer += chunk; | |
| handleDataStream(data); | |
| checkAndRespond(stderrBuffer); | |
| if (stderrBuffer.length > 1000) stderrBuffer = stderrBuffer.slice(-1000); | |
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding quotes around the JAVA_HOME path on Windows can cause issues. Environment variable values should not include quotes - the operating system handles paths with spaces correctly without them. This could break Java execution if the JDK tools don't expect quoted paths.