-
-
Notifications
You must be signed in to change notification settings - Fork 209
/
hdr.ps1
24 lines (20 loc) · 838 Bytes
/
hdr.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
param($target = "C:\Dev\Github\WireMock.Net")
$header = "// Copyright © WireMock.Net
"
function Write-Header ($file) {
$content = Get-Content $file -Raw # Using -Raw to read the entire file as a single string
$filename = Split-Path -Leaf $file
if ($content.TrimStart().StartsWith($header.Trim())) {
# Write-Host "Skipping existing: $filename"
} elseif ($content.TrimStart().StartsWith("// <auto-generated>")) {
# Write-Host "Skipping auto-generated file: $filename"
} else {
Write-Host "Prepend the header for file: $filename"
Set-Content $file $header
Add-Content $file $content -NoNewline # Writing back to the file without an extra newline
}
}
Get-ChildItem $target -Recurse | ? { $_.Extension -like ".cs" } | % `
{
Write-Header $_.PSPath.Split(":", 3)[2]
}