-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathbuild.ps1
52 lines (41 loc) · 1.35 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#DO NOT USE THIS EXCEPT FOR CREATING THE FINAL SCRIPT
function Add-FslRelease {
[cmdletbinding()]
param (
[Parameter(
ValuefromPipelineByPropertyName = $true
)]
[System.String]$FunctionsFolder = '.\Functions',
[Parameter(
ValuefromPipelineByPropertyName = $true
)]
[System.String]$ReleaseFile,
[Parameter(
ValuefromPipelineByPropertyName = $true
)]
[System.String]$ControlScript
)
$ctrlScript = Get-Content -Path $ControlScript
$funcs = Get-ChildItem $FunctionsFolder -File | Where-Object { $_.Name -ne $ControlScript }
foreach ($funcName in $funcs) {
$pattern = "#$($funcName.BaseName)"
$pattern = ". .\Functions\Private\$($funcName.BaseName)"
$actualFunc = Get-Content $funcName.FullName
$ctrlScript = $ctrlScript | Foreach-Object {
if ($_ -like "*$pattern*" ) {
$actualFunc
}
else {
$_
}
}
}
$ctrlScript | Set-Content $ReleaseFile
}
$path = 'C:\PoShCode\Invoke-FslShrinkDisk'
$p = @{
FunctionsFolder = Join-Path $path 'Functions\Private'
ReleaseFile = Join-Path $path 'Invoke-FslShrinkDisk.ps1'
ControlScript = Join-Path $path 'Functions\Public\Invoke-FslShrinkDisk.ps1'
}
Add-FslRelease @p