-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathUpdateSavedPatterns.md.irregular.ps1
41 lines (32 loc) · 1.3 KB
/
UpdateSavedPatterns.md.irregular.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
try {
$IrregularModuleRoot = Get-Module Irregular | Split-Path | Select-Object -First 1
$sortedRegexes = @(Get-Regex | Sort-Object Name)
$savedPatternsMarkdown = @(
'### Irregular Patterns'
@"
Irregular includes $($sortedRegexes.Count) regular expressions
"@
@($sortedRegexes | # Gets all saved Regular Expressions as a Markdown table
ForEach-Object -Begin {
'|Name|Description|IsGenerator|'
'|:---|:----------|:----------|'
} -Process {
$reg = $_
$desc = $_.Description
$desc = if ($desc) {$desc | ?<NewLine> -Replace '<br/>'} else { ''}
$link =
if ($reg.Path) {
"[$($reg.Name)]($($reg.Path.Replace($IrregularModuleRoot, '')))" -replace '\\', '/'
} else {
$reg.Name
}
"|$link|$desc|$($_.IsGenerator)|"
}) -join [Environment]::NewLine -replace '<br/>\|', '|'
)
$savedPatternsMarkdown | Set-Content .\SavedPatterns.md -Encoding UTF8
Get-Item .\SavedPatterns.md |
Add-Member NoteProperty CommitMessage "Updating SavedPatterns.md [skip ci]" -Force -PassThru
} catch {
$ex = $_
$ex | Format-Custom| Out-Host
}