Skip to content

Commit

Permalink
update output types of utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
admercs committed Feb 20, 2024
1 parent 172e9ec commit 5313b34
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions scripts/utils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ NOTES:
###

function Test-VariableDefined {
[OutputType(Boolean)]
param(
[Parameter(Mandatory)]
[String]
$Variable
)
return [Boolean](Get-Variable $Variable -ErrorAction SilentlyContinue)
return Get-Variable $Variable -ErrorAction SilentlyContinue
}

function Test-WorkingDirectory {
[OutputType()]
$WorkingDirectory = Split-Path "$PWD" -Leaf
if ($WorkingDirectory -ne 'AutonomySim') {
Write-Output "Present working directory: ${PWD}"
Expand All @@ -35,6 +37,7 @@ function Test-WorkingDirectory {
}

function Add-Directories {
[OutputType()]
param(
[Parameter()]
[String[]]
Expand All @@ -46,6 +49,7 @@ function Add-Directories {
}

function Remove-Directories {
[OutputType()]
param(
[Parameter()]
[String[]]
Expand All @@ -57,6 +61,7 @@ function Remove-Directories {
}

function Invoke-Fail {
[OutputType()]
param(
[Parameter()]
[String]
Expand All @@ -82,8 +87,20 @@ function Invoke-Fail {
}
}

function Get-EnvVariables {
return Get-ChildItem 'env:*' | Sort-Object 'Name' | Format-List
function Get-Exceptions {
[OutputType([String[]])]
[String[]]$Exceptions = [AppDomain]::CurrentDomain.GetAssemblies() | foreach {
try {
$_.GetExportedTypes().BaseType | Where { $_.Fullname -Match 'Exception' }
} catch {}
}
return $Exceptions | Sort-Object -Unique
}

function Get-EnvVars {
[OutputType([Object[]])]
[Object[]]$EnvVars = Get-ChildItem 'env:*' | Sort-Object 'Name' | Format-List
return $EnvVars
}

function Get-ProgramVersion {
Expand All @@ -93,7 +110,7 @@ function Get-ProgramVersion {
[String]
$Program
)
return (Get-Command -Name $Program -ErrorAction SilentlyContinue).Version
return (Get-Command -Name "$Program" -ErrorAction SilentlyContinue).Version
}

function Get-VersionMajorMinor {
Expand All @@ -117,12 +134,14 @@ function Get-VersionMajorMinorBuild {
}

function Get-WindowsInfo {
[OutputType([PSCustomObject])]
param(
[Parameter(Mandatory)]
[System.Object]
$Info
)
return $Info | Select-Object WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer
[PSCustomObject]$SystemInfo = $Info | Select-Object WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer
return $SystemInfo
}

function Get-WindowsVersion {
Expand Down

0 comments on commit 5313b34

Please sign in to comment.