-
Notifications
You must be signed in to change notification settings - Fork 420
/
Copy pathmark-shipped.ps1
52 lines (45 loc) · 1.5 KB
/
mark-shipped.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
[CmdletBinding(PositionalBinding=$false)]
param ()
Set-StrictMode -version 2.0
$ErrorActionPreference = "Stop"
function MarkShipped([Parameter(mandatory=$true)][string]$dir,
[Parameter(mandatory=$true)][string]$access) {
$shippedFileName = $access + "API.Shipped.txt"
$shippedFilePath = Join-Path $dir $shippedFileName
$shipped = @()
$shipped += Get-Content $shippedFilePath
$unshippedFileName = $access + "API.Unshipped.txt"
$unshippedFilePath = Join-Path $dir $unshippedFileName
$unshipped = Get-Content $unshippedFilePath
$removed = @()
$removedPrefix = "*REMOVED*";
Write-Host "Processing $dir : $access"
foreach ($item in $unshipped) {
if ($item.Length -gt 0) {
if ($item.StartsWith($removedPrefix)) {
$item = $item.Substring($removedPrefix.Length)
$removed += $item
}
else {
$shipped += $item
}
}
}
$shipped | Sort-Object -Unique |Where-Object { -not $removed.Contains($_) } | Out-File $shippedFilePath -Encoding Ascii
Clear-Content $unshippedFilePath
}
try {
foreach ($file in Get-ChildItem -re -in "PublicApi.Shipped.txt") {
$dir = Split-Path -parent $file
MarkShipped $dir "Public"
}
foreach ($file in Get-ChildItem -re -in "InternalApi.Shipped.txt") {
$dir = Split-Path -parent $file
MarkShipped $dir "Internal"
}
}
catch {
Write-Host $_
Write-Host $_.Exception
exit 1
}