Skip to content

Commit f27f228

Browse files
committedApr 3, 2023
Compile module into single file
1 parent 83c280a commit f27f228

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+101
-215
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Custom
2+
BuildOutput
3+
14
## Ignore Visual Studio temporary files, build results, and
25
## files generated by popular Visual Studio add-ons.
36

‎AutomatedLab.Common/.build/build.ps1

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Prepare and write new content to module instead of dot-sourcing
2+
# Get public and private function definition files.
3+
$importFolders = Get-ChildItem $env:BHPSModulePath -Exclude (Split-Path -Path $env:BHBuildOutput -Leaf) -Include Types, Public, Private -Recurse -Directory -ErrorAction SilentlyContinue
4+
5+
$sb = [System.Text.StringBuilder]::new()
6+
$publicList = [System.Collections.ArrayList]::new()
7+
foreach ($line in (Get-Content (Join-Path $env:BHPSModulePath AutomatedLab.Common.psm1)))
8+
{
9+
if ($line -match '^\$importFolders') { break }
10+
11+
$null = $sb.AppendLine()
12+
$null = $sb.Append($line)
13+
}
14+
15+
foreach ($file in (Get-ChildItem -Recurse -Path $importFolders -Filter *.ps1))
16+
{
17+
if ($file.Directory.Name -eq 'Public')
18+
{
19+
$null = $publicList.Add($file.Basename)
20+
}
21+
22+
$null = $sb.AppendLine()
23+
$null = $sb.Append((Get-Content -Raw -Path $file.FullName))
24+
}
25+
26+
$null = $sb.AppendLine()
27+
$null = $sb.AppendLine("Export-ModuleMember -Function $($publicList -join ',')")
28+
$sb.ToString() | Set-Content (Join-Path $env:BHBuildOutput AutomatedLab.Common\AutomatedLab.Common.psm1)
29+
30+
Copy-Item -Force -Path $env:BHPSModuleManifest -Destination (Join-Path $env:BHBuildOutput AutomatedLab.Common\AutomatedLab.Common.psd1)
31+
Update-ModuleManifest -Path (Join-Path $env:BHBuildOutput AutomatedLab.Common\AutomatedLab.Common.psd1) -FunctionsToExport $publicList

0 commit comments

Comments
 (0)