-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge_script.ps1
38 lines (32 loc) · 872 Bytes
/
merge_script.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
Set-StrictMode -Version Latest
function Remove-LeadingComment {
param([string[]]$lines)
$index = 0
while($index -lt $lines.Count) {
if (!$lines[$index].StartsWith("#")) {
break
}
$index++
}
if ($index -lt $lines.Count) {
$lines[$index..($lines.Count-1)]
}
}
function Get-MergedScript {
param([string]$Path)
try {
$Path = Resolve-Path $Path
$c = Get-Content -Path "$Path\NtObjectManager.psm1" | Out-String
$i = $c.IndexOf("# Source the external scripts into this module.")
$res = $c.Substring(0, $i)
$fs = ls "$Path\*.ps1"
foreach($f in $fs) {
$c = Get-Content -Path $f.FullName
$c = Remove-LeadingComment $c | Out-String
$res += $c
}
$res
} catch {
Write-Error $_
}
}