Skip to content

Commit 0614dc7

Browse files
authored
Merge pull request #238 from jwittner/fix/moduleJsonVersionSearch
2 parents 1845a9f + 7c8ee2a commit 0614dc7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,16 +1245,20 @@ function Get-UnitySetupInstanceVersion {
12451245

12461246
# Try to look in the modules.json file for installer paths that contain version info
12471247
if ( Test-Path "$path\modules.json" -PathType Leaf ) {
1248+
try {
1249+
Write-Verbose "Searching $path\modules.json for module versions"
1250+
$table = (Get-Content "$path\modules.json" -Raw) | ConvertFrom-Json -AsHashtable
12481251

1249-
Write-Verbose "Searching $path\modules.json for module versions"
1250-
$modules = (Get-Content "$path\modules.json" -Raw) | ConvertFrom-Json
1251-
1252-
foreach ( $module in $modules ) {
1253-
Write-Verbose "`tTesting DownloadUrl $($module.DownloadUrl)"
1254-
if ( $module.DownloadUrl -notmatch "(\d+)\.(\d+)\.(\d+)([fpab])(\d+)" ) { continue; }
1252+
foreach ( $url in $table.downloadUrl ) {
1253+
Write-Debug "`tTesting DownloadUrl $url"
1254+
if ( $url -notmatch "(\d+)\.(\d+)\.(\d+)([fpab])(\d+)" ) { continue; }
12551255

1256-
Write-Verbose "`tFound version!"
1257-
return [UnityVersion]$Matches[0]
1256+
Write-Verbose "`tFound version!"
1257+
return [UnityVersion]$Matches[0]
1258+
}
1259+
}
1260+
catch {
1261+
Write-Verbose "Error parsing $path\modules.json:`n`t$_"
12581262
}
12591263
}
12601264

0 commit comments

Comments
 (0)