Skip to content

Commit c69fe7c

Browse files
committed
Remove old files when building reference
1 parent 85c1ba9 commit c69fe7c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/scripts/builders/reference.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ export const buildReference = async () => {
4343
...(await convertDocsToMDX(Object.values(parsedOutput.classitems))),
4444
...(await convertDocsToMDX(Object.values(parsedOutput.classes))),
4545
];
46+
47+
// Remove the old .mdx files so that reference items that no longer
48+
// exist don't linger
49+
const existing = await fs.readdir(prefix)
50+
for (const f of existing) {
51+
if ((await fs.lstat(path.join(prefix, f))).isDirectory()) {
52+
await fs.rmdir(path.join(prefix, f), { recursive: true });
53+
}
54+
}
55+
4656
// Save the MDX files to the file system
4757
await saveMDX(mdxDocs);
4858
console.log("Done building reference docs!");

0 commit comments

Comments
 (0)