-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapply-license-header.ps1
62 lines (45 loc) · 1.82 KB
/
apply-license-header.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
53
54
55
56
57
58
59
60
61
62
# Copyright (c) 2023 Sander van Vliet
# Licensed under Artistic License 2.0
# See LICENSE or https://choosealicense.com/licenses/artistic-2.0/
$csharpFiles = Get-ChildItem -Recurse -Filter *.cs | where-object {!$_.fullname.Contains("\obj\") -and !$_.fullname.Contains("\bin\")}
$prepend = Get-Content "csharp-license.txt" -Raw
foreach($file in $csharpFiles)
{
$contents = get-content $file -head 1
if(!$contents.Trim().StartsWith("// Copyright (c) "))
{
$fullPath = $file.FullName
Write-Host "$fullPath doesn't have a license header"
$rawContents = Get-Content $file -Raw
$targetContent = $prepend + $rawContents
Set-Content $file $targetContent
}
}
$xamlFiles = Get-ChildItem -Recurse -Filter *.axaml | where-object {!$_.fullname.Contains("\obj\") -and !$_.fullname.Contains("\bin\")}
$prepend = Get-Content "xaml-license.txt" -Raw
foreach($file in $xamlFiles)
{
$contents = get-content $file -head 2
if(!$contents[1].Trim().StartsWith("// Copyright (c) "))
{
$fullPath = $file.FullName
Write-Host "$fullPath doesn't have a license header"
$rawContents = Get-Content $file -Raw
$targetContent = $prepend + $rawContents
Set-Content $file $targetContent
}
}
$powershellFiles = Get-ChildItem -Recurse -Filter *.ps1 | where-object {!$_.fullname.Contains("\obj\") -and !$_.fullname.Contains("\bin\")}
$prepend = Get-Content "powershell-license.txt" -Raw
foreach($file in $powershellFiles)
{
$contents = get-content $file -head 1
if(!$contents.Trim().StartsWith("# Copyright (c) "))
{
$fullPath = $file.FullName
Write-Host "$fullPath doesn't have a license header"
$rawContents = Get-Content $file -Raw
$targetContent = $prepend + $rawContents
Set-Content $file $targetContent
}
}