@@ -541,23 +541,25 @@ describe('InitCommand - profile and detection features', () => {
541541 const opencodeHome = path . join ( os . tmpdir ( ) , `openspec-opencode-home-${ Date . now ( ) } ` ) ;
542542 process . env . OPENCODE_HOME = opencodeHome ;
543543
544- // Create legacy OpenCode command files (singular 'command' path)
545- const legacyDir = path . join ( testDir , '.opencode' , 'command' ) ;
546- await fs . mkdir ( legacyDir , { recursive : true } ) ;
547- await fs . writeFile ( path . join ( legacyDir , 'opsx-propose.md' ) , 'legacy content' ) ;
548-
549- // Run init in non-interactive mode without --force
550- const initCommand = new InitCommand ( { tools : 'opencode' } ) ;
551- await initCommand . execute ( testDir ) ;
552-
553- // Legacy files should be cleaned up automatically
554- expect ( await fileExists ( path . join ( legacyDir , 'opsx-propose.md' ) ) ) . toBe ( false ) ;
544+ try {
545+ // Create legacy OpenCode command files (singular 'command' path)
546+ const legacyDir = path . join ( testDir , '.opencode' , 'command' ) ;
547+ await fs . mkdir ( legacyDir , { recursive : true } ) ;
548+ await fs . writeFile ( path . join ( legacyDir , 'opsx-propose.md' ) , 'legacy content' ) ;
549+
550+ // Run init in non-interactive mode without --force
551+ const initCommand = new InitCommand ( { tools : 'opencode' } ) ;
552+ await initCommand . execute ( testDir ) ;
555553
556- // New commands should be at the global OpenCode path
557- const newCommandsDir = path . join ( opencodeHome , 'commands' ) ;
558- expect ( await directoryExists ( newCommandsDir ) ) . toBe ( true ) ;
554+ // Legacy files should be cleaned up automatically
555+ expect ( await fileExists ( path . join ( legacyDir , 'opsx-propose.md' ) ) ) . toBe ( false ) ;
559556
560- await fs . rm ( opencodeHome , { recursive : true , force : true } ) ;
557+ // New commands should be at the global OpenCode path
558+ const newCommandsDir = path . join ( opencodeHome , 'commands' ) ;
559+ expect ( await directoryExists ( newCommandsDir ) ) . toBe ( true ) ;
560+ } finally {
561+ await fs . rm ( opencodeHome , { recursive : true , force : true } ) ;
562+ }
561563 } ) ;
562564
563565 it ( 'should preselect configured tools but not directory-detected tools in extend mode' , async ( ) => {
0 commit comments