Skip to content

Commit

Permalink
flip Get-SupportedArchitecture conditions to reduce nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
brian6932 committed Oct 17, 2023
1 parent a269210 commit 892832f
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions lib/manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,30 @@ function arch_specific($prop, $manifest, $architecture) {
}

function Get-SupportedArchitecture($manifest, $architecture) {
if (!$manifest.architecture.$architecture) {
if ($architecture -eq 'arm64') {
# Windows 10 enables existing unmodified x86 apps to run on Arm devices.
# Windows 11 adds the ability to run unmodified x64 Windows apps on Arm devices!
# Ref: https://learn.microsoft.com/en-us/windows/arm/overview
$architecture = if ($WindowsBuild -ge 22000) {
# Windows 11
'64bit'
} else {
# Windows 10
'32bit'
}
} elseif ($architecture[-3] -eq '-') {
$success = $false
for ($i = $architecture[-1] - [byte][char]'0'; $i -gt 1; --$i) {
$testArch = "64bit-v$i"
if ($manifest.architecture.$testArch) {
$success = $true
break
}
if ($manifest.architecture.$architecture -and ![String]::IsNullOrEmpty((arch_specific 'url' $manifest $architecture))) {
return $architecture
}
if ($architecture -eq 'arm64') {
# Windows 10 enables existing unmodified x86 apps to run on Arm devices.
# Windows 11 adds the ability to run unmodified x64 Windows apps on Arm devices!
# Ref: https://learn.microsoft.com/en-us/windows/arm/overview
$architecture = if ($WindowsBuild -ge 22000) {
# Windows 11
'64bit'
} else {
# Windows 10
'32bit'
}
} elseif ($architecture[-3] -eq '-') {
$success = $false
for ($i = $architecture[-1] - [byte][char]'0'; $i -gt 1; --$i) {
$testArch = "64bit-v$i"
if ($manifest.architecture.$testArch) {
$success = $true
break
}
$architecture = if ($success) { $testArch } else { '64bit' }
}
}
if (![String]::IsNullOrEmpty((arch_specific 'url' $manifest $architecture))) {
return $architecture
$architecture = if ($success) { $testArch } else { '64bit' }
}
}

Expand Down

0 comments on commit 892832f

Please sign in to comment.