2025-12-06 00:24:51 +08:00
|
|
|
import fs from "node:fs/promises";
|
2025-12-08 10:18:39 +08:00
|
|
|
import commonmarkTestSuite from "commonmark-test-suite";
|
2025-12-06 00:24:51 +08:00
|
|
|
|
2025-12-08 10:18:39 +08:00
|
|
|
const existing = new Set(
|
|
|
|
|
Object.values(commonmarkTestSuite).flatMap((release) =>
|
|
|
|
|
release.testCases.map(({ markdown }) => markdown.trim()),
|
|
|
|
|
),
|
2025-12-06 00:24:51 +08:00
|
|
|
);
|
|
|
|
|
|
2025-12-08 10:18:39 +08:00
|
|
|
const DIRECTORIES = [
|
|
|
|
|
new URL("../tests/format/markdown/spec-legacy/", import.meta.url),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
for (const directory of DIRECTORIES) {
|
|
|
|
|
for (const file of await fs.readdir(directory, { withFileTypes: true })) {
|
|
|
|
|
if (!file.isFile()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const fileUrl = new URL(file.name, directory);
|
|
|
|
|
const content = await fs.readFile(fileUrl, "utf8");
|
|
|
|
|
if (existing.has(content.trim())) {
|
|
|
|
|
await fs.rm(new URL(file.name, directory));
|
|
|
|
|
}
|
2025-12-06 00:24:51 +08:00
|
|
|
}
|
|
|
|
|
}
|