44#>
55[CmdletBinding ()]
66Param (
7- [String []]$TaskNames = (' clean' , ' build' , ' test' , ' updateManifest' , ' publish' , ' updateHelp' , ' generateShortNamesMapping' , ' push' ),
7+ [ValidateSet (' clean' , ' build' , ' updateManifest' , ' publish' , ' updateHelp' , ' generateShortNamesMapping' , ' push' )]
8+ [String []]$TaskNames = (' clean' , ' build' , ' updateManifest' , ' publish' , ' updateHelp' , ' generateShortNamesMapping' , ' push' ),
9+ [ValidateSet (' origin' , ' homotechsual' )]
810 [String []]$Remotes = @ (' origin' , ' homotechsual' ),
911 [Hashtable ]$BuildConfig = (
10- Join-Path - Path $PSScriptRoot - ChildPath ' buildConfig .psd1' | Import-PowerShellDataFile - LiteralPath { $_ } - ErrorAction SilentlyContinue
12+ Join-Path - Path $PSScriptRoot - ChildPath ' Source ' | Join-Path - ChildPath ' build .psd1' | Import-PowerShellDataFile - LiteralPath { $_ } - ErrorAction SilentlyContinue
1113 ),
1214 [Switch ]$ExcludeCustomTasks = $false ,
1315 [System.Management.Automation.SemanticVersion ]$SemVer
@@ -20,14 +22,28 @@ if (-Not(Get-Module -Name 'Install-RequiredModule')) {
2022Install-RequiredModule - RequiredModulesFile (' {0}\RequiredModules.psd1' -f $PSScriptRoot ) - Scope CurrentUser - TrustRegisteredRepositories - Import - Quiet
2123# Use strict mode when building.
2224Set-StrictMode - Version Latest
25+ # Helper: Get the module PSD1 file path.
26+ function GetModulePath {
27+ [CmdletBinding ()]
28+ param (
29+ [Parameter (Mandatory )]
30+ [String ]$ModuleName
31+ )
32+ $ModulePath = (Get-ChildItem - Path (' {0}\Output\*\*\{1}.psd1' -f $PSScriptRoot , $ModuleName )).FullName
33+ if (! (Test-Path - Path $ModulePath )) {
34+ throw (' Module {0} not found at "{1}".' -f $ModuleName , $ModulePath )
35+ }
36+ return $ModulePath
37+ }
2338# Helper: Get functions from the module.
2439function GetFunctions {
2540 [CmdletBinding ()]
2641 param (
2742 [Parameter (Mandatory )]
2843 [String ]$ModuleName
2944 )
30- Import-Module (' .\Source\{0}.psd1' -f $Script :ModuleName ) - Force
45+ $ModulePath = GetModulePath - ModuleName $ModuleName
46+ Import-Module $ModulePath - Force
3147 $Module = Get-Module - Name $Script :ModuleName
3248 $CommandletList = [System.Collections.Generic.List [String ]]::new()
3349 $CommandletList.AddRange ($Module.ExportedFunctions.Keys )
@@ -90,7 +106,7 @@ This page has been generated from the {0} PowerShell module source. To make chan
90106'@ -f $Script :ModuleName
91107 $ExcludeFiles = Get-ChildItem - Path " $ ( $PSScriptRoot ) \Private" - Filter ' *.ps1' - Recurse | ForEach-Object { [System.IO.Path ]::GetFileNameWithoutExtension($_.FullName ) }
92108 $NewDocusaurusHelpParams = @ {
93- Module = (' .\Source\{0}.psd1 ' -f $Script :ModuleName )
109+ Module = (GetModulePath - ModuleName $Script :ModuleName )
94110 DocsFolder = $DocsFolderPath
95111 Exclude = $ExcludeFiles
96112 Sidebar = ' commandlets'
@@ -226,37 +242,6 @@ This page has been generated from the {0} PowerShell module source. To make chan
226242function Build {
227243 Build-Module - Path ' .\Source' - SemVer $SemVer.ToString ()
228244}
229- # Task: Copy PowerShell Module files to output folder for release on PSGallery
230- function CopyModuleFiles {
231- # Copy Module Files to Output Folder
232- if (-not (Test-Path " $ ( $PSScriptRoot ) \Output\$Script :ModuleName " )) {
233- New-Item - Path " $ ( $PSScriptRoot ) \Output\$Script :ModuleName " - ItemType Directory | Out-Null
234- }
235- if (Test-Path - Path " $ ( $PSScriptRoot ) \Classes\" ) {
236- Copy-Item - Path " $ ( $PSScriptRoot ) \Classes\" - Filter * .* - Recurse - Destination " $ ( $PSScriptRoot ) \Output\$Script :ModuleName " - Force
237- }
238- if (Test-Path - Path " $ ( $PSScriptRoot ) \Data\" ) {
239- Copy-Item - Path " $ ( $PSScriptRoot ) \Data\" - Filter * .* - Recurse - Destination " $ ( $PSScriptRoot ) \Output\$Script :ModuleName " - Force
240- }
241- Copy-Item - Path " $ ( $PSScriptRoot ) \Private\" - Filter * .* - Recurse - Destination " $ ( $PSScriptRoot ) \Output\$Script :ModuleName " - Force
242- Copy-Item - Path " $ ( $PSScriptRoot ) \Public\" - Filter * .* - Recurse - Destination " $ ( $PSScriptRoot ) \Output\$Script :ModuleName " - Force
243-
244- # Copy module, manifest and scaffold files
245- Copy-Item - Path @ (
246- " $ ( $PSScriptRoot ) \LICENSE.md"
247- " $ ( $PSScriptRoot ) \CHANGELOG.md"
248- " $ ( $PSScriptRoot ) \README.md"
249- " $ ( $PSScriptRoot ) \$Script :ModuleName .psd1"
250- " $ ( $PSScriptRoot ) \$Script :ModuleName .psm1"
251- ) - Destination " $ ( $PSScriptRoot ) \Output\$Script :ModuleName " - Force
252- }
253- # Task: Run all Pester tests in folder .\Tests
254- function Test {
255- $Result = Invoke-Pester " $ ( $PSScriptRoot ) \Tests" - PassThru
256- if ($Result.FailedCount -gt 0 ) {
257- throw ' Pester tests failed'
258- }
259- }
260245# Task: Update the Module Manifest file with info from the Changelog.
261246function UpdateManifest {
262247 # Import PlatyPS. Needed for parsing the versions in the Changelog.
0 commit comments