-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathBuildModule.ps1
More file actions
34 lines (30 loc) · 1.18 KB
/
BuildModule.ps1
File metadata and controls
34 lines (30 loc) · 1.18 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
function Build-Module {
$data = Get-MTProjectInfo
$MTBuildVersion = (Get-Command Invoke-MTBuild).Version
Write-Verbose "Running ModuleTols Version: $MTBuildVersion"
Write-Verbose 'Buidling module psm1 file'
Test-ProjectSchema -Schema Build | Out-Null
$sb = [System.Text.StringBuilder]::new()
# Classes Folder
$files = Get-ChildItem -Path $data.ClassesDir -Filter *.ps1 -ErrorAction SilentlyContinue
$files | ForEach-Object {
$sb.AppendLine([IO.File]::ReadAllText($_.FullName)) | Out-Null
}
# Public Folder
$files = Get-ChildItem -Path $data.PublicDir -Filter *.ps1
$files | ForEach-Object {
$sb.AppendLine([IO.File]::ReadAllText($_.FullName)) | Out-Null
}
# Private Folder
$files = Get-ChildItem -Path $data.PrivateDir -Filter *.ps1 -ErrorAction SilentlyContinue
if ($files) {
$files | ForEach-Object {
$sb.AppendLine([IO.File]::ReadAllText($_.FullName)) | Out-Null
}
}
try {
Set-Content -Path $data.ModuleFilePSM1 -Value $sb.ToString() -Encoding 'UTF8' -ErrorAction Stop # psm1 file
} catch {
Write-Error 'Failed to create psm1 file' -ErrorAction Stop
}
}