-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild-PSModuleBase.ps1
More file actions
48 lines (42 loc) · 1.92 KB
/
Build-PSModuleBase.ps1
File metadata and controls
48 lines (42 loc) · 1.92 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
function Build-PSModuleBase {
<#
.SYNOPSIS
Compiles the base module files.
.DESCRIPTION
This function will compile the base module files.
It will copy the source files to the output folder and remove the files that are not needed.
.EXAMPLE
Build-PSModuleBase -SourceFolderPath 'C:\MyModule\src\MyModule' -OutputFolderPath 'C:\MyModule\build\MyModule'
#>
[CmdletBinding()]
#Requires -Modules @{ ModuleName = 'GitHub'; ModuleVersion = '0.13.2' }
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSReviewUnusedParameter', '', Scope = 'Function',
Justification = 'LogGroup - Scoping affects the variables line of sight.'
)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSAvoidUsingWriteHost', '', Scope = 'Function',
Justification = 'Want to just write to the console, not the pipeline.'
)]
param(
# Name of the module.
[Parameter(Mandatory)]
[string] $ModuleName,
# Path to the folder where the module source code is located.
[Parameter(Mandatory)]
[System.IO.DirectoryInfo] $ModuleSourceFolder,
# Path to the folder where the built modules are outputted.
[Parameter(Mandatory)]
[System.IO.DirectoryInfo] $ModuleOutputFolder
)
LogGroup 'Build base' {
$relModuleSourceFolder = $ModuleSourceFolder | Resolve-Path -Relative
$relModuleOutputFolder = $ModuleOutputFolder | Resolve-Path -Relative
Write-Host "Copying files from [$relModuleSourceFolder] to [$relModuleOutputFolder]"
Copy-Item -Path "$ModuleSourceFolder\*" -Destination $ModuleOutputFolder -Recurse -Force -Exclude "$ModuleName.psm1"
$null = New-Item -Path $ModuleOutputFolder -Name "$ModuleName.psm1" -ItemType File -Force
}
LogGroup 'Build base - Result' {
Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force | Resolve-Path -Relative | Sort-Object
}
}