File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -367,33 +367,35 @@ function Detect-OS {
367367
368368 $response = " "
369369
370- # Detect Windows (PowerShell 5 or PowerShell 7 on Windows)
371- if ($IsWindows ) {
370+ # Detect OS using .NET APIs
371+ $isWindows = [System.Runtime.InteropServices.RuntimeInformation ]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform ]::Windows)
372+ $isLinux = [System.Runtime.InteropServices.RuntimeInformation ]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform ]::Linux)
373+ $isMacOS = [System.Runtime.InteropServices.RuntimeInformation ]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform ]::OSX)
374+
375+ if ($isWindows ) {
372376 $response = " windows"
373377 }
374- # Detect macOS
375- elseif ($IsMacOS ) {
378+ elseif ($isMacOS ) {
376379 $response = " macos"
377380 }
378- # Detect Linux (could be WSL or native Linux)
379- elseif ($IsLinux ) {
380-
381- # Detect WSL
381+ elseif ($isLinux ) {
382+ # Check if WSL
382383 $procVersion = " "
383384 if (Test-Path " /proc/version" ) {
384385 $procVersion = Get-Content " /proc/version" - ErrorAction SilentlyContinue
385386 }
386387
387388 if ($procVersion -match " microsoft" ) {
388389 $response = " wsl"
389- } else {
390+ }
391+ else {
390392 $response = " linux"
391393 }
392394 }
393395 else {
394396 $response = " unknown"
395397 }
396398
397- # Export (PowerShell equivalent)
399+ # Export (PowerShell equivalent of export )
398400 $env: NOW_OS = $response
399- }
401+ }
You can’t perform that action at this time.
0 commit comments