-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
69 lines (56 loc) · 2.32 KB
/
build.ps1
File metadata and controls
69 lines (56 loc) · 2.32 KB
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
66
67
68
69
#!/usr/bin/env pwsh
#Requires -Version 5.1
<#
.SYNOPSIS
Builds YFridelance.PS.ModuleFactory using itself (dogfooding).
.DESCRIPTION
This script imports the dev version of YFridelance.PS.ModuleFactory and uses
Build-PSModule to create the distributable version in ./dist/.
.EXAMPLE
./build.ps1
Builds the module to ./dist/YFridelance.PS.ModuleFactory/
.EXAMPLE
./build.ps1 -Clean
Cleans the output directory before building.
#>
[CmdletBinding()]
param(
[switch]$Clean,
[string]$Prerelease
)
$ErrorActionPreference = 'Stop'
# Import the dev version of the module
$ModulePath = Join-Path -Path $PSScriptRoot -ChildPath 'YFridelance.PS.ModuleFactory'
Write-Host "Importing module from: $ModulePath" -ForegroundColor Cyan
Import-Module -Name $ModulePath -Force -Verbose:$false
# Build the module
$OutputPath = Join-Path -Path $PSScriptRoot -ChildPath (Join-Path -Path 'dist' -ChildPath 'YFridelance.PS.ModuleFactory')
$BuildParams = @{
Path = $ModulePath
OutputPath = $OutputPath
Verbose = $true
}
if ($Clean) {
$BuildParams['Clean'] = $true
}
Write-Host "`nBuilding YFridelance.PS.ModuleFactory..." -ForegroundColor Cyan
$Result = Build-PSModule @BuildParams
if ($Result.Success) {
Write-Host "`nBuild successful!" -ForegroundColor Green
Write-Host " Output: $($Result.OutputPath)" -ForegroundColor Green
Write-Host " Functions: $($Result.FunctionsExported -join ', ')" -ForegroundColor Green
Write-Host " Aliases: $($Result.AliasesExported -join ', ')" -ForegroundColor Green
Write-Host " Files: $($Result.FilesMerged) files merged" -ForegroundColor Green
if ($Prerelease) {
# Dot-source the private helper (not exported by the module)
. (Join-Path -Path $ModulePath -ChildPath (Join-Path -Path 'Private' -ChildPath 'Update-ManifestField.ps1'))
$Script:DefaultEncoding = [System.Text.UTF8Encoding]::new($true)
$BuiltManifestPath = Join-Path -Path $OutputPath -ChildPath 'YFridelance.PS.ModuleFactory.psd1'
Update-ManifestField -ManifestPath $BuiltManifestPath -FieldName 'Prerelease' -Value $Prerelease
Write-Host " Prerelease: $Prerelease" -ForegroundColor Green
}
}
else {
Write-Host "`nBuild failed!" -ForegroundColor Red
exit 1
}