()
| 91 | } |
| 92 | |
| 93 | async function verifyMarkdownLinks() { |
| 94 | // Find all markdown files in docs directory |
| 95 | const markdownFiles = await glob('docs/**/*.md', { |
| 96 | ignore: ['**/node_modules/**'], |
| 97 | }) |
| 98 | |
| 99 | console.log(`Found ${markdownFiles.length} markdown files\n`) |
| 100 | |
| 101 | // Process each file |
| 102 | for (const file of markdownFiles) { |
| 103 | const content = readFileSync(file, 'utf-8') |
| 104 | const links: Array<string> = markdownLinkExtractor(content) |
| 105 | |
| 106 | const relativeLinks = links.filter((link: string) => { |
| 107 | return isRelativeLink(link) |
| 108 | }) |
| 109 | |
| 110 | if (relativeLinks.length > 0) { |
| 111 | relativeLinks.forEach((link) => { |
| 112 | relativeLinkExists(link, file) |
| 113 | }) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | if (errors.length > 0) { |
| 118 | console.log(`\n❌ Found ${errors.length} broken links:`) |
| 119 | errors.forEach((err) => { |
| 120 | console.log( |
| 121 | `${err.file}\n link: ${err.link}\n resolved: ${err.resolvedPath}\n why: ${err.reason}\n`, |
| 122 | ) |
| 123 | }) |
| 124 | process.exit(1) |
| 125 | } else { |
| 126 | console.log('\n✅ No broken links found!') |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | verifyMarkdownLinks().catch(console.error) |
no test coverage detected