mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 13:17:54 +00:00
replace 2>&1 to Get-CommandResult
This commit is contained in:
@@ -5,14 +5,16 @@ function Get-OSName {
|
||||
}
|
||||
|
||||
function Get-CPPVersions {
|
||||
$cppVersions = apt list --installed 2>&1 | Where-Object { $_ -match "g\+\+-\d+"} | ForEach-Object {
|
||||
$result = Get-CommandResult "apt list --installed" -Multiline
|
||||
$cppVersions = $result.Output | Where-Object { $_ -match "g\+\+-\d+"} | ForEach-Object {
|
||||
& $_.Split("/")[0] --version | Select-Object -First 1 | Take-OutputPart -Part 3
|
||||
} | Sort-Object {[Version]$_}
|
||||
return "GNU C++ " + ($cppVersions -Join ", ")
|
||||
}
|
||||
|
||||
function Get-FortranVersions {
|
||||
$fortranVersions = apt list --installed 2>&1 | Where-Object { $_ -match "^gfortran-\d+"} | ForEach-Object {
|
||||
$result = Get-CommandResult "apt list --installed" -Multiline
|
||||
$fortranVersions = $result.Output | Where-Object { $_ -match "^gfortran-\d+"} | ForEach-Object {
|
||||
$_ -match "now (?<version>\d+\.\d+\.\d+)-" | Out-Null
|
||||
$Matches.version
|
||||
} | Sort-Object {[Version]$_}
|
||||
@@ -21,7 +23,8 @@ function Get-FortranVersions {
|
||||
|
||||
function Get-ClangVersions {
|
||||
$clangVersions = @()
|
||||
$clangVersions = apt list --installed 2>&1 | Where-Object { $_ -match "^clang-\d+"} | ForEach-Object {
|
||||
$result = Get-CommandResult "apt list --installed" -Multiline
|
||||
$clangVersions = $result.Output | Where-Object { $_ -match "^clang-\d+"} | ForEach-Object {
|
||||
$clangCommand = ($_ -Split "/")[0]
|
||||
Invoke-Expression "$clangCommand --version" | Where-Object { $_ -match "clang version" } | ForEach-Object {
|
||||
$_ -match "clang version (?<version>\d+\.\d+\.\d+)-" | Out-Null
|
||||
@@ -153,14 +156,15 @@ function Get-MavenVersion {
|
||||
return "Maven $mavenVersion"
|
||||
}
|
||||
function Get-SbtVersion {
|
||||
$result = sbt -version 2>&1 | Out-String
|
||||
$result -match "sbt script version: (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$result = Get-CommandResult "sbt -version"
|
||||
$result.Output -match "sbt script version: (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$sbtVersion = $Matches.version
|
||||
return "Sbt $sbtVersion"
|
||||
}
|
||||
|
||||
function Get-PHPVersions {
|
||||
return $(apt list --installed 2>&1) | Where-Object { $_ -match "^php\d+\.\d+/"} | ForEach-Object {
|
||||
$result = Get-CommandResult "apt list --installed" -Multiline
|
||||
return $result.Output | Where-Object { $_ -match "^php\d+\.\d+/"} | ForEach-Object {
|
||||
$_ -match "now (?<version>\d+\.\d+\.\d+)-" | Out-Null
|
||||
$Matches.version
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user