🎨 (Analyze dead links): Prettier output

Make a headline named 'Dead links found' and add each dead link on a new line
This commit is contained in:
Frederik Hjorslev Poulsen 2020-04-06 12:55:12 +02:00
parent 156114245b
commit 311845151a
No known key found for this signature in database
GPG Key ID: 23DDBC920BDE66CF

View File

@ -1,7 +1,7 @@
function Test-MarkdownLinks([String]$Path) {
$unreachable = @()
# Get markdown files recursively
$files = Get-ChildItem -Path $path -Recurse -Include "*.md"
$files = Get-ChildItem -Path $Path -Recurse -Include "*.md"
$files | ForEach-Object {
$fileName = $_.Name
@ -26,7 +26,11 @@
return $unreachable
}
$deadlinks = Test-MarkdownLinks -Path ".\readme.md"
if ($deadlinks) {
Write-Error -Message 'Dead links found' -Category ObjectNotFound
$DeadLinks = Test-MarkdownLinks -Path ".\readme.md"
if ($DeadLinks) {
Write-Host -Object '--- DEAD LINKS FOUND ---' -ForegroundColor Red
foreach ($DeadLink in $DeadLinks) {
Write-Host -Object $DeadLink -ForegroundColor Red
}
exit 1
}