Skip to content

Commit 7f412d5

Browse files
committed
chore: updated generate-api-docs to preserve index.mdx
1 parent f0f37b5 commit 7f412d5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

scripts/generate-api-docs.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ async function generateApiDocs(options) {
9191
console.log(`📂 Examples Output: ${examplesOutputDir}`);
9292

9393
try {
94+
// Back up index.mdx if it exists
95+
const indexPath = path.join(apiOutputDir, "index.mdx");
96+
let indexBackup = null;
97+
try {
98+
indexBackup = await fs.readFile(indexPath, "utf8");
99+
console.log("💾 Backing up existing index.mdx...");
100+
} catch (error) {
101+
// index.mdx doesn't exist, no need to back up
102+
}
103+
94104
// Clean up previous runs
95105
console.log("🧹 Cleaning up previous runs...");
96106
await fs.rm(tempDir, { recursive: true, force: true });
@@ -185,6 +195,12 @@ async function generateApiDocs(options) {
185195
process.chdir(originalDir);
186196
}
187197

198+
// Restore index.mdx if it was backed up
199+
if (indexBackup) {
200+
console.log("♻️ Restoring index.mdx...");
201+
await fs.writeFile(indexPath, indexBackup, "utf8");
202+
}
203+
188204
// Clean up temporary directory
189205
console.log("🧹 Cleaning up...");
190206
await fs.rm(tempDir, { recursive: true, force: true });

0 commit comments

Comments
 (0)