Skip to content

Commit 342a15a

Browse files
search modules.json first as a recursive file search may be slower
1 parent 48e4aab commit 342a15a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,7 @@ class UnitySetupInstance {
5252
$version = $null
5353
$currentOS = Get-OperatingSystem
5454

55-
# First we'll attempt to search for the version using the ivy.xml definitions for legacy editor compatibility.
56-
$ivy = Get-ChildItem -Path $path -Filter ivy.xml -Recurse -ErrorAction SilentlyContinue -Force | Select-Object -First 1
57-
58-
if ( Test-Path $ivy.FullName ) {
59-
[xml]$xmlDoc = Get-Content $ivy.FullName
60-
$version = [UnityVersion]$xmlDoc.'ivy-module'.info.unityVersion
61-
}
62-
else {
63-
# No ivy files found, so search the new modules.json for the version
55+
if ( Test-Path "$path\modules.json" ) {
6456
$modules = (Get-Content "$path\modules.json" -Raw) | ConvertFrom-Json
6557

6658
foreach ( $module in $modules ) {
@@ -72,6 +64,15 @@ class UnitySetupInstance {
7264
}
7365
}
7466
}
67+
else {
68+
# We'll attempt to search for the version using the ivy.xml definitions for legacy editor compatibility.
69+
$ivy = Get-ChildItem -Path $path -Filter ivy.xml -Recurse -ErrorAction SilentlyContinue -Force | Select-Object -First 1
70+
71+
if ( Test-Path $ivy.FullName ) {
72+
[xml]$xmlDoc = Get-Content $ivy.FullName
73+
$version = [UnityVersion]$xmlDoc.'ivy-module'.info.unityVersion
74+
}
75+
}
7576

7677
if ( $version -eq $null ) {
7778
throw "Failed to find a valid installation at $path!";

0 commit comments

Comments
 (0)