.gitlab/UpdateModule.ps1
#! /usr/bin/pwsh # ______________________________________________ # | | # # | UpdateModule.ps1 | # # |______________________________________________| # # Pathing. Write-Host "executed in $PSScriptRoot'."; $SEPARATOR = [System.IO.Path]::DirectorySeparatorChar; $PATH_NAME = (Split-Path $PSScriptRoot -Parent) + $SEPARATOR + 'config' + $SEPARATOR + 'name.env'; $PATH_VERSION = (Split-Path $PSScriptRoot -Parent) + $SEPARATOR + 'config' + $SEPARATOR + 'version.env'; $NAME = Get-Content -Path "$PATH_NAME" -TotalCount 1; $VERSION = Get-Content -Path "$PATH_VERSION" -TotalCount 1; $PATH_MANIFEST = (Split-Path $PSScriptRoot -Parent) + $SEPARATOR + $NAME + '.psd1'; $PATH_PUB = (Split-Path $PSScriptRoot -Parent) + $SEPARATOR + 'src' + $SEPARATOR + 'windows' + $SEPARATOR + 'public'; # Listing. $currentManifest = Test-ModuleManifest $PATH_MANIFEST; $publicFunctions = Get-ChildItem -Path $PATH_PUB | Where-Object { ($_.Name -cmatch "^[A-Z]") -And ($_.Extension -eq '.ps1') }; $functionsAdded = $publicFunctions | Where-Object {$_.BaseName -notin $currentManifest.ExportedFunctions.Keys}; $functionsRemoved = $currentManifest.ExportedFunctions.Keys | Where-Object {$_ -notin $publicFunctions.BaseName}; # Test : what add ? if ($functionsAdded -or $functionsRemoved) { try { $updateModuleManifestParams = @{} $updateModuleManifestParams.Add('Path', $PATH_MANIFEST) $updateModuleManifestParams.Add('ErrorAction', 'Stop') if ($publicFunctions.Count -gt 0) { $updateModuleManifestParams.Add('ModuleVersion', $VERSION); $updateModuleManifestParams.Add('FunctionsToExport', $publicFunctions.BaseName); } Update-ModuleManifest @updateModuleManifestParams } catch { $_ | Write-Error } } Write-Host "manifest updated at '${PATH_MANIFEST}'."; |