(testDataPath: string)
| 49 | } |
| 50 | |
| 51 | function crawlNewReferenceFiles(testDataPath: string): TestResultEntry[] { |
| 52 | const out: TestResultEntry[] = []; |
| 53 | function visit(dir: string, name: string): void { |
| 54 | const handle = fs.opendirSync(dir); |
| 55 | try { |
| 56 | while (true) { |
| 57 | const entry = handle.readSync(); |
| 58 | if (!entry) { |
| 59 | break; |
| 60 | } |
| 61 | if (entry.isDirectory() && entry.name !== '.' && entry.name !== '..') { |
| 62 | visit(path.join(dir, entry.name), `${name}/${entry.name}`); |
| 63 | } else if (entry.isFile() && entry.name.endsWith('.new.png')) { |
| 64 | out.push({ |
| 65 | originalFile: `${name}/${entry.name.replace('.new.png', '.png')}`, |
| 66 | newFile: `${name}/${entry.name}`, |
| 67 | diffFile: `${name}/${entry.name.replace('.new.png', '.diff.png')}` |
| 68 | }); |
| 69 | } |
| 70 | } |
| 71 | } finally { |
| 72 | handle.close(); |
| 73 | } |
| 74 | } |
| 75 | visit(testDataPath, 'test-data'); |
| 76 | return out; |
| 77 | } |
| 78 | |
| 79 | export default function server(): Plugin { |
| 80 | return { |
no test coverage detected