@@ -635,51 +635,32 @@ export default TurboModuleRegistry.getEnforcing<Spec>('${moduleName}');
635635 }
636636 }
637637
638- private async removeOldArchWindowsDirectory ( ) : Promise < void > {
638+ private async handleExistingWindowsDirectory ( ) : Promise < void > {
639639 const windowsDir = path . join ( this . root , 'windows' ) ;
640+ const windowsOldDir = path . join ( this . root , 'windows_old' ) ;
640641
641642 if ( await fs . exists ( windowsDir ) ) {
642643 this . verboseMessage (
643- " Found existing windows directory, checking if it's old architecture ..." ,
644+ ' Found existing windows directory, renaming to windows_old ...' ,
644645 ) ;
645646
646647 try {
647- // Check if this looks like an old architecture windows directory
648- // Old arch typically has specific files/structure that differ from new arch
649- const oldArchIndicators = [
650- 'ReactNativeModule.cpp' ,
651- 'ReactNativeModule.h' ,
652- 'pch.h' ,
653- 'packages.config' ,
654- '*.vcxproj' ,
655- ] ;
656-
657- let hasOldArchFiles = false ;
658- for ( const indicator of oldArchIndicators ) {
659- const matches = glob . sync ( indicator , { cwd : windowsDir } ) ;
660- if ( matches . length > 0 ) {
661- hasOldArchFiles = true ;
662- this . verboseMessage ( `Found old architecture file: ${ matches [ 0 ] } ` ) ;
663- break ;
664- }
648+ // If windows_old already exists, remove it first
649+ if ( await fs . exists ( windowsOldDir ) ) {
650+ this . verboseMessage ( 'Removing existing windows_old directory...' ) ;
651+ await fs . rmdir ( windowsOldDir , { recursive : true } ) ;
665652 }
666653
667- if ( hasOldArchFiles ) {
668- this . verboseMessage ( 'Removing old architecture windows directory...' ) ;
669- await fs . rmdir ( windowsDir , { recursive : true } ) ;
670- this . verboseMessage (
671- 'Old architecture windows directory removed successfully' ,
672- ) ;
673- } else {
674- this . verboseMessage (
675- 'Windows directory appears to be new architecture, keeping it' ,
676- ) ;
677- }
654+ // Rename windows to windows_old
655+ await fs . rename ( windowsDir , windowsOldDir ) ;
656+ this . verboseMessage (
657+ 'Successfully renamed windows directory to windows_old' ,
658+ ) ;
678659 } catch ( error : any ) {
679660 this . verboseMessage (
680- `Warning: Could not remove old windows directory: ${ error . message } ` ,
661+ `Warning: Could not rename windows directory: ${ error . message } ` ,
681662 ) ;
682- // Don't fail the entire process if we can't remove the old directory
663+ // Don't fail the entire process if we can't rename the directory
683664 // The overwrite flag in init-windows should handle most conflicts
684665 }
685666 }
@@ -1208,9 +1189,9 @@ ${defaultImplementations}
12081189 spinner . text = 'Upgrading dependencies...' ;
12091190
12101191 await this . upgradeDependencies ( ) ;
1211- spinner . text = 'Checking for old architecture Windows directory...' ;
1192+ spinner . text = 'Handling existing Windows directory...' ;
12121193
1213- await this . removeOldArchWindowsDirectory ( ) ;
1194+ await this . handleExistingWindowsDirectory ( ) ;
12141195 spinner . text = 'Setting up Windows library...' ;
12151196
12161197 await this . runInitWindows ( config ) ;
0 commit comments