| 16 | export const wrap = (Base: typeof TestRunner): typeof TestRunner => { |
| 17 | return class DoctestRunner extends Base { |
| 18 | override importFile(filepath: string, source: "collect" | "setup"): unknown { |
| 19 | if (source !== "collect") { |
| 20 | return super.importFile(filepath, source) |
| 21 | } |
| 22 | |
| 23 | return readFile(filepath).then((contents) => { |
| 24 | if (!contents.includes("import.meta.vitest")) { |
| 25 | return super.importFile(filepath, source) |
| 26 | } |
| 27 | |
| 28 | const version = createHash("sha256").update(contents).digest("hex").slice(0, 16) |
| 29 | return super.importFile(Protocol.collectorId(filepath, version), source) |
| 30 | }) |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |