Overwrite categorized profile files

This commit is contained in:
Manuel Thalmann 2024-03-20 22:56:04 +01:00
parent 38a109e6dc
commit a640da02ae

View file

@ -6,7 +6,7 @@ $null = New-Module {
[string]$Category = $null, [string]$Category = $null,
[Parameter(Position=0, Mandatory=$true)] [Parameter(Position=0, Mandatory=$true)]
[string]$Statement, [string]$Statement,
[switch]$Overwrite = $false [switch]$Overwrite
) )
[System.Collections.Generic.List[string]] $shells = @(); [System.Collections.Generic.List[string]] $shells = @();
@ -29,6 +29,10 @@ $null = New-Module {
$profiles = $profiles | ForEach-Object { [System.IO.Path]::GetRelativePath($(Get-Location), $_); }; $profiles = $profiles | ForEach-Object { [System.IO.Path]::GetRelativePath($(Get-Location), $_); };
if ($Category) { if ($Category) {
if (-not $($Overwrite.IsPresent)) {
$Overwrite = $true;
}
$profiles = $profiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "profile.d" "$Category.ps1"; }; $profiles = $profiles | ForEach-Object { Join-Path (Split-Path -Parent $_) "profile.d" "$Category.ps1"; };
} }