Skip to content

Commit 3094378

Browse files
committed
Added simple script to merge powershell module.
1 parent 698f580 commit 3094378

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

merge_script.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Set-StrictMode -Version Latest
2+
3+
function Remove-LeadingComment {
4+
param([string[]]$lines)
5+
6+
$index = 0
7+
while($index -lt $lines.Count) {
8+
if (!$lines[$index].StartsWith("#")) {
9+
break
10+
}
11+
$index++
12+
}
13+
if ($index -lt $lines.Count) {
14+
$lines[$index..($lines.Count-1)]
15+
}
16+
}
17+
18+
function Get-MergedScript {
19+
param([string]$Path)
20+
21+
try {
22+
$Path = Resolve-Path $Path
23+
24+
$c = Get-Content -Path "$Path\NtObjectManager.psm1" | Out-String
25+
$i = $c.IndexOf("# Source the external scripts into this module.")
26+
27+
$res = $c.Substring(0, $i)
28+
$fs = ls "$Path\*.ps1"
29+
foreach($f in $fs) {
30+
$c = Get-Content -Path $f.FullName
31+
$c = Remove-LeadingComment $c | Out-String
32+
$res += $c
33+
}
34+
$res
35+
} catch {
36+
Write-Error $_
37+
}
38+
}

0 commit comments

Comments
 (0)