Skip to content

Commit 4337fe7

Browse files
committed
Fix Windows build detection without OS env var
1 parent 4e7982b commit 4337fe7

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

build.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ function Write-Info($text) { Write-Host " $text" -ForegroundColor Gray }
5454
# Track issues
5555
$issues = @()
5656

57+
function Test-WindowsHost {
58+
$isWindowsVariable = Get-Variable -Name IsWindows -ErrorAction SilentlyContinue
59+
if ($isWindowsVariable) {
60+
return [bool]$isWindowsVariable.Value
61+
}
62+
63+
return [System.Environment]::OSVersion.Platform -eq [System.PlatformID]::Win32NT
64+
}
65+
5766
function ConvertTo-GitSafeDirectoryPath($path) {
5867
return ([System.IO.Path]::GetFullPath($path).TrimEnd("\") -replace "\\", "/")
5968
}
@@ -143,7 +152,7 @@ Write-Host @"
143152
Write-Header "Checking Prerequisites"
144153

145154
# Check OS
146-
if ($env:OS -ne "Windows_NT") {
155+
if (-not (Test-WindowsHost)) {
147156
Write-Error "This project requires Windows"
148157
exit 1
149158
}

0 commit comments

Comments
 (0)