Skip to content

Commit

Permalink
Merge pull request #124 from szymonos/feat/install-utils-020
Browse files Browse the repository at this point in the history
feat: InstallUtils v0.2.0
  • Loading branch information
szymonos authored Oct 2, 2023
2 parents a2d6556 + 7a9c4c0 commit c9c0234
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
40 changes: 40 additions & 0 deletions modules/InstallUtils/Functions/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,46 @@ function Invoke-CommandRetry {
} until ($exit)
}

function Join-Str {
[CmdletBinding()]
[OutputType([string])]
param (
[Parameter(Mandatory, ValueFromPipeline = $true)]
[string[]]$InputObject,

[string]$Separator = ' ',

[Parameter(ParameterSetName = 'Single')]
[switch]$SingleQuote,

[Parameter(ParameterSetName = 'Double')]
[switch]$DoubleQuote
)

begin {
# instantiate list to store quoted elements
$lst = [System.Collections.Generic.List[string]]::new()
# calculate quote char
$quote = if ($SingleQuote) {
"'"
} elseif ($DoubleQuote) {
'"'
} else {
''
}
}

process {
# quote input elements
$lst.Add("${quote}$_${quote}")
}

end {
# return joined elements
return [string]::Join($Separator, $lst)
}
}

function Test-IsAdmin {
$currentIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$principal = [System.Security.Principal.WindowsPrincipal]$currentIdentity
Expand Down
3 changes: 2 additions & 1 deletion modules/InstallUtils/InstallUtils.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'InstallUtils.psm1'

# Version number of this module.
ModuleVersion = '0.1.0'
ModuleVersion = '0.2.0'

# Supported PSEditions
CompatiblePSEditions = @('Core', 'Desk')
Expand Down Expand Up @@ -72,6 +72,7 @@
FunctionsToExport = @(
# common
'Invoke-CommandRetry'
'Join-Str'
'Test-IsAdmin'
'Update-SessionEnvironmentPath'
# git
Expand Down
1 change: 1 addition & 0 deletions modules/InstallUtils/InstallUtils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ $exportModuleMemberParams = @{
Function = @(
# common
'Invoke-CommandRetry'
'Join-Str'
'Test-IsAdmin'
'Update-SessionEnvironmentPath'
# git
Expand Down

0 comments on commit c9c0234

Please sign in to comment.