Skip to content

Commit a5389d0

Browse files
unity-cli@v1.3.4
- fix elevated permissions check on windows - fix java exceptions on linux android installation
1 parent 8736559 commit a5389d0

5 files changed

Lines changed: 24 additions & 11 deletions

File tree

.github/workflows/unity-build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ jobs:
4242
run: |
4343
unity-cli hub-install --auto-update
4444
unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-target }}" --json
45+
- name: Clean Disk Space
46+
if: ${{ matrix.os == 'ubuntu-latest' }}
47+
shell: bash
48+
run: |
49+
echo "Disk space before cleanup:"
50+
df -h
51+
sudo rm -rf /usr/local/.ghcup
52+
sudo rm -rf /opt/hostedtoolcache/CodeQL
53+
sudo rm -rf /usr/local/lib/android/sdk/ndk
54+
sudo rm -rf /opt/ghc
55+
echo "Disk space after cleanup:"
56+
df -h
4557
- name: Verify UNITY_HUB_PATH and UNITY_EDITOR_PATH variables
4658
shell: bash
4759
run: |

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.3",
3+
"version": "1.3.4",
44
"description": "A command line utility for the Unity Game Engine.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",

src/android-sdk.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ async function getSdkManager(rootEditorPath: string): Promise<string> {
8686
default:
8787
throw new Error(`Unsupported platform: ${process.platform}`);
8888
}
89+
8990
const sdkmanagerPath = await ResolveGlobToPath(globPath);
9091

9192
if (!sdkmanagerPath) {
@@ -103,7 +104,6 @@ async function getAndroidSdkPath(rootEditorPath: string, androidTargetSdk: numbe
103104

104105
try {
105106
sdkPath = await ResolveGlobToPath([rootEditorPath, '**', 'PlaybackEngines', 'AndroidPlayer', 'SDK', 'platforms', `android-${androidTargetSdk}/`]);
106-
await fs.promises.access(sdkPath, fs.constants.R_OK);
107107
} catch (error) {
108108
logger.debug(`android-${androidTargetSdk} not installed`);
109109
return undefined;
@@ -124,12 +124,12 @@ async function execSdkManager(sdkManagerPath: string, javaPath: string, args: st
124124
}
125125

126126
try {
127-
exitCode = await new Promise<number>((resolve, reject) => {
127+
exitCode = await new Promise<number>(async (resolve, reject) => {
128128
let cmd = sdkManagerPath;
129129
let cmdArgs = args;
130130

131131
if (process.platform === 'win32') {
132-
if (!isProcessElevated()) {
132+
if (!await isProcessElevated()) {
133133
throw new Error('Android SDK installation requires elevated (administrator) privileges. Please rerun as Administrator.');
134134
}
135135

@@ -140,6 +140,7 @@ async function execSdkManager(sdkManagerPath: string, javaPath: string, args: st
140140
const child = spawn(cmd, cmdArgs, {
141141
stdio: ['pipe', 'pipe', 'pipe'],
142142
env: {
143+
...process.env,
143144
JAVA_HOME: process.platform === 'win32' ? `"${javaPath}"` : javaPath
144145
}
145146
});

src/utilities.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,11 +578,11 @@ export async function KillChildProcesses(procInfo: ProcInfo): Promise<void> {
578578
* Checks if the current process is running with elevated (administrator) privileges.
579579
* @returns True if the process is elevated, false otherwise.
580580
*/
581-
export function isProcessElevated(): boolean {
581+
export async function isProcessElevated(): Promise<boolean> {
582582
if (process.platform !== 'win32') { return true; } // We can sudo easily on non-windows platforms
583-
const probe = spawnSync('powershell.exe', [
583+
const output = await Exec('powershell', [
584584
'-NoLogo', '-NoProfile', '-Command',
585-
"[Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent().IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)"
586-
], { encoding: 'utf8' });
587-
return probe.status === 0 && probe.stdout.trim().toLowerCase() === 'true';
585+
"(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)"
586+
], { silent: true, showCommand: false });
587+
return output.trim().toLowerCase() === 'true';
588588
}

0 commit comments

Comments
 (0)