Process a md file. Rewrites the file content if custom ids are needed.
(path: string)
| 103 | |
| 104 | /** Process a md file. Rewrites the file content if custom ids are needed. */ |
| 105 | async function processFile(path: string): Promise<void> { |
| 106 | const context = await fs.readFile(path, {encoding: 'utf-8'}); |
| 107 | let changed = false; |
| 108 | const lines = context.split('\n').map(line => { |
| 109 | const customId = getCustomId(line); |
| 110 | if (customId) { |
| 111 | changed = true; |
| 112 | return customId.join(' '); |
| 113 | } |
| 114 | return line; |
| 115 | }); |
| 116 | if (changed) { |
| 117 | console.log(path); |
| 118 | await fs.writeFile(path, lines.join('\n')); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | /** Recursively get all files within the given directory. */ |
| 123 | async function listFiles(path: string, extension: string): Promise<string[]> { |
no test coverage detected
searching dependent graphs…