-
-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathGenerateDependencyTable.ps1
More file actions
48 lines (38 loc) · 1.35 KB
/
GenerateDependencyTable.ps1
File metadata and controls
48 lines (38 loc) · 1.35 KB
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
$target = ".\THIRD_PARTY_NOTICES.md"
$generated = (nuget-license -i .\CollapseLauncher.sln -o Markdown | Out-String).TrimEnd("`r", "`n")
$existing = Get-Content $target -Raw
$day = (Get-Date).Day
$suffix = if ($day -in 11..13) {
"th"
} elseif ($day % 10 -eq 1) {
"st"
} elseif ($day % 10 -eq 2) {
"nd"
} elseif ($day % 10 -eq 3) {
"rd"
} else {
"th"
}
$dateStamp = (Get-Date -Format "MMMM ") + "$day$suffix, " + (Get-Date -Format "yyyy")
$existing = $existing -replace `
"This page lists the third-party software dependencies used in CollapseLauncher\..*",
"This page lists the third-party software dependencies used in CollapseLauncher. Autogenerated by nuget-license at $dateStamp."
$pattern = "(?s)<!-- BEGIN NUGET-LICENSES -->.*?<!-- END NUGET-LICENSES -->"
$replacement = "<!-- BEGIN NUGET-LICENSES -->`n$generated`n<!-- END NUGET-LICENSES -->"
($existing -replace $pattern, $replacement) | Set-Content $target -NoNewline
$status = git diff -- $gitPath
if ([string]::IsNullOrWhiteSpace($status))
{
git add $target 2>$null
if ($LASTEXITCODE -ne 0) {
Write-Host "No license changes detected."
return
}
git commit -m "[skip ci]chore: update third-party dependency licenses"
#git push 2>$null
if ($LASTEXITCODE -ne 0) {
throw "git push failed"
}
} else {
Write-Host "No license changes detected."
}