BuildHelpers.psm1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#Get public and private function definition files. $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue ) $Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) # $ModuleRoot = $PSScriptRoot #Dot source the files Foreach($import in @($Public + $Private)) { Try { . $import.fullname } Catch { Write-Error -Message "Failed to import function $($import.fullname): $_" } } # Load dependencies. TODO: Move to module dependency once the bug that # causes this is fixed: https://ci.appveyor.com/project/RamblingCookieMonster/buildhelpers/build/1.0.22 # Thanks to Joel Bennett for this! $fallbackModule = Get-Module -Name $PSScriptRoot\Private\Modules\Configuration -ListAvailable if ($configModule = Get-Module $fallbackModule.Name -ListAvailable) { $configModule | Where-Object { $_.Version -gt $fallbackModule.Version} | Sort-Object -Property Version -Descending | Select-Object -First 1 | Import-Module -Force } if (-not (Get-Module $fallbackModule.Name | Where-Object { $_.Version -gt $fallbackModule.Version})) { $fallbackModule | Import-Module -Force } Export-ModuleMember -Function $Public.Basename Export-ModuleMember -Function Get-Metadata, Update-Metadata, Export-Metadata # Set aliases (#10) Set-Alias -Name Set-BuildVariable -Value $PSScriptRoot\Scripts\Set-BuildVariable.ps1 Set-Alias -Name Get-NextPSGalleryVersion -Value Get-NextNugetPackageVersion # Backwards compatibilty to command names prior to #72 Set-Alias -Name Get-BuildVariables -Value Get-BuildVariable Set-Alias -Name Get-ModuleAliases -Value Get-ModuleAlias Set-Alias -Name Get-ModuleFunctions -Value Get-ModuleFunction Set-Alias -Name Set-ModuleAliases -Value Set-ModuleAlias Set-Alias -Name Set-ModuleFormats -Value Set-ModuleFormat Set-Alias -Name Set-ModuleFunctions -Value Set-ModuleFunction Set-Alias -Name Set-ModuleTypes -Value Set-ModuleType $exportModuleMemberSplat = @{ Alias = @( 'Set-BuildVariable' 'Get-NextPSGalleryVersion' 'Get-BuildVariables' 'Get-ModuleAliases' 'Get-ModuleFunctions' 'Set-ModuleAliases' 'Set-ModuleFormats' 'Set-ModuleFunctions' 'Set-ModuleTypes' ) } Export-ModuleMember @exportModuleMemberSplat |