From bf8932c578c5642b5df28e987c57293b3385b9b2 Mon Sep 17 00:00:00 2001 From: Matheus Costa Date: Sun, 28 Dec 2025 13:08:39 -0300 Subject: [PATCH 1/2] fix: Improve Unity version checks and license activation Refactored getUnityExecutablePath for conciseness and updated isUnityVersionInstalled to use async fs.pathExists. Added credential validation to license activation, returning an error if required credentials are missing. --- src/unityEditor.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/unityEditor.ts b/src/unityEditor.ts index 1af9417..995f2b4 100644 --- a/src/unityEditor.ts +++ b/src/unityEditor.ts @@ -67,9 +67,7 @@ class UnityEditor { public static getUnityExecutablePath(version: string): string { const platform = os.platform() as keyof typeof UnityEditor.UNITY_PATHS; const unityConfig = UnityEditor.UNITY_PATHS[platform]; - - const unityPath = path.join(unityConfig.base, version, unityConfig.executable); - return unityPath; + return path.join(unityConfig.base, version, unityConfig.executable); } /** @@ -93,9 +91,8 @@ class UnityEditor { public static async isUnityVersionInstalled(version: string): Promise { try { const unityPath = this.getUnityExecutablePath(version); - return fs.existsSync(unityPath); + return await fs.pathExists(unityPath); } catch (error) { - console.error(error); return false; } } @@ -308,6 +305,10 @@ class UnityEditor { ): Promise> { console.debug(`Activating Unity license for version ${projectInfo.editorVersion}`); + if (!serial || !username || !password) { + return err(new UnityLicenseError('Missing required credentials', { projectInfo })); + } + const args = ["-quit", "-serial", serial, "-username", username, "-password", password]; const editorInfo = { version: projectInfo.editorVersion }; From 1c22979c5a800e930d21488b4f0166d2c283098d Mon Sep 17 00:00:00 2001 From: Matheus Costa Date: Sun, 28 Dec 2025 13:12:42 -0300 Subject: [PATCH 2/2] fix: validation check for potentially causing misleading error Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/unityEditor.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/unityEditor.ts b/src/unityEditor.ts index 995f2b4..cdc76f0 100644 --- a/src/unityEditor.ts +++ b/src/unityEditor.ts @@ -305,8 +305,12 @@ class UnityEditor { ): Promise> { console.debug(`Activating Unity license for version ${projectInfo.editorVersion}`); - if (!serial || !username || !password) { - return err(new UnityLicenseError('Missing required credentials', { projectInfo })); + const hasMissingCredentials = [serial, username, password].some( + (value) => value == null || value.trim().length === 0 + ); + + if (hasMissingCredentials) { + return err(new UnityLicenseError("Missing required credentials", { projectInfo })); } const args = ["-quit", "-serial", serial, "-username", username, "-password", password];