File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff 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 } ) ;
You can’t perform that action at this time.
0 commit comments