Skip to content

Commit a251175

Browse files
authored
Merge pull request #23 from NoTaskStudios/fix/validation-adjusments
fix: Improve Unity version checks and license activation
2 parents 8eb9329 + 1c22979 commit a251175

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/unityEditor.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ class UnityEditor {
6767
public static getUnityExecutablePath(version: string): string {
6868
const platform = os.platform() as keyof typeof UnityEditor.UNITY_PATHS;
6969
const unityConfig = UnityEditor.UNITY_PATHS[platform];
70-
71-
const unityPath = path.join(unityConfig.base, version, unityConfig.executable);
72-
return unityPath;
70+
return path.join(unityConfig.base, version, unityConfig.executable);
7371
}
7472

7573
/**
@@ -93,9 +91,8 @@ class UnityEditor {
9391
public static async isUnityVersionInstalled(version: string): Promise<boolean> {
9492
try {
9593
const unityPath = this.getUnityExecutablePath(version);
96-
return fs.existsSync(unityPath);
94+
return await fs.pathExists(unityPath);
9795
} catch (error) {
98-
console.error(error);
9996
return false;
10097
}
10198
}
@@ -308,6 +305,14 @@ class UnityEditor {
308305
): Promise<Result<void, UnityEditorNotFoundError | UnityCommandError | UnityLicenseError>> {
309306
console.debug(`Activating Unity license for version ${projectInfo.editorVersion}`);
310307

308+
const hasMissingCredentials = [serial, username, password].some(
309+
(value) => value == null || value.trim().length === 0
310+
);
311+
312+
if (hasMissingCredentials) {
313+
return err(new UnityLicenseError("Missing required credentials", { projectInfo }));
314+
}
315+
311316
const args = ["-quit", "-serial", serial, "-username", username, "-password", password];
312317

313318
const editorInfo = { version: projectInfo.editorVersion };

0 commit comments

Comments
 (0)