-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.ps1
37 lines (27 loc) · 1.36 KB
/
build.ps1
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
param (
$sourceFolder = $PSScriptRoot,
$destinationFolder = 'output',
[switch]
$BootStrap
)
if ($BootStrap) {
if (-not (Get-Module -ListAvailable -Name platyPS)) {
Find-Module -Name PlatyPs | Install-Module -Scope CurrentUser -Force
}
}
$manifestFileInfo = Get-ChildItem -Path $PSScriptRoot -Filter *.psd1
$moduleManifest = Import-PowerShellDataFile -Path $manifestFileInfo
$destinationPath = Join-Path -Path $sourceFolder -ChildPath $destinationFolder
$helpPath = Join-Path -Path $destinationPath -ChildPath 'en-US'
$publicFunctions = Get-ChildItem -Path $PSScriptRoot -Include Public -Recurse | Get-ChildItem -Filter *.ps1
if (Test-Path -Path $destinationPath) {
Remove-Item -Path $destinationPath -Force -Confirm:$false -Recurse
}
$null = New-Item -ItemType Directory -Path $destinationPath
$publicFunctions | ForEach-Object {
Get-Content $_.FullName | Add-Content -Path (Join-Path -Path $destinationPath -ChildPath $moduleManifest.RootModule)
}
$content = Get-Content -Path $manifestFileInfo.FullName
$content -replace "^FunctionsToExport = '[*]'$", ("FunctionsToExport = @('{0}'`r`n)" -f ($publicFunctions.BaseName -join "',`r`n`t'")) |
Set-Content -Path (Join-Path -Path $destinationPath -ChildPath $manifestFileInfo.Name)
$null = New-ExternalHelp -Path (join-path -Path $sourceFolder -ChildPath 'docs') -OutputPath $helpPath