(outputDir: string)
| 77 | } |
| 78 | |
| 79 | async function trimTrailingWhitespaceInMarkdown(outputDir: string) { |
| 80 | const entries = await readdir(outputDir, { withFileTypes: true }) |
| 81 | |
| 82 | await Promise.all( |
| 83 | entries.map(async (entry) => { |
| 84 | const path = resolve(outputDir, entry.name) |
| 85 | |
| 86 | if (entry.isDirectory()) { |
| 87 | await trimTrailingWhitespaceInMarkdown(path) |
| 88 | return |
| 89 | } |
| 90 | |
| 91 | if (!entry.isFile() || !path.endsWith('.md')) { |
| 92 | return |
| 93 | } |
| 94 | |
| 95 | const markdown = await readFile(path, 'utf8') |
| 96 | const trimmed = markdown.replace(/[ \t]+$/gm, '') |
| 97 | |
| 98 | if (trimmed !== markdown) { |
| 99 | await writeFile(path, trimmed) |
| 100 | } |
| 101 | }), |
| 102 | ) |
| 103 | } |
| 104 | |
| 105 | async function addRedirectFromToFileFrontmatter( |
| 106 | filePath: string, |
no test coverage detected