Files
runner-images/images/macos/helpers/SoftwareReport.Helpers.psm1
Sergey Dolin 6beed71b4f Document environment variables of MacOS images (#2493)
* Document environment variables of MacOS images

* Change adnroid variables

* Apply reviews

* Remove some variables, fix headers

* Show link targets

* rename helper

* remove symlinks

* More links
2021-02-08 09:45:16 +03:00

52 lines
1.3 KiB
PowerShell

function Run-Command {
param (
[Parameter(Mandatory=$true)]
[string] $Command,
[switch] $SuppressStderr
)
# Bash trick to suppress and show error output because some commands write to stderr (for example, "python --version")
$redirectOutputArguments = If ($SuppressStderr) { "2> /dev/null" } Else { "2>&1" }
$stdout = & bash -c "${Command} ${redirectOutputArguments}"
return $stdout
}
function Take-Part {
param (
[Parameter(ValueFromPipeline)]
[string] $toolOutput,
[string] $Delimiter = " ",
[int[]] $Part
)
$parts = $toolOutput.Split($Delimiter, [System.StringSplitOptions]::RemoveEmptyEntries)
$selectedParts = $parts[$Part]
return [string]::Join($Delimiter, $selectedParts)
}
function New-MDNewLine {
param (
[int] $Count = 1
)
$newLineSymbol = [System.Environment]::NewLine
return $newLineSymbol * $Count
}
function Get-LinkTarget {
param (
[string] $inputPath
)
$link = Get-Item $inputPath | Select-Object -ExpandProperty Target
if ($link) {
return " -> $link"
}
return ""
}
function Get-PathWithLink {
param (
[string] $inputPath
)
$link = Get-LinkTarget($inputPath)
return "${inputPath}${link}"
}