File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,16 @@ const { usePHPVersion } = require('../commands/use');
1111function  findPHPVMRCFile ( startDir  =  process . cwd ( ) )  { 
1212  let  currentDir  =  startDir ; 
1313
14-   while  ( currentDir   !==   '/' )  { 
14+   while  ( true )  { 
1515    const  phpvmrcPath  =  path . join ( currentDir ,  '.phpvmrc' ) ; 
1616    if  ( fs . existsSync ( phpvmrcPath ) )  { 
1717      return  phpvmrcPath ; 
1818    } 
19-     currentDir  =  path . resolve ( currentDir ,  '..' ) ; 
19+ 
20+     const  parentDir  =  path . resolve ( currentDir ,  '..' ) ; 
21+     if  ( parentDir  ===  currentDir )  break ;  // Stop if we've reached the root directory 
22+ 
23+     currentDir  =  parentDir ; 
2024  } 
2125
2226  return  null ; 
@@ -41,10 +45,10 @@ async function autoSwitchPHPVersion() {
4145    }  catch  ( error )  { 
4246      console . error ( `Failed to switch to PHP ${ version }  : ${ error . message }  ` ) ; 
4347    } 
44-   }  else  { 
45-     // Silent if no .phpvmrc file is found 
46-     return ; 
4748  } 
49+ 
50+   // Silent return when no .phpvmrc is found 
51+   return ; 
4852} 
4953
5054module . exports  =  {  findPHPVMRCFile,  autoSwitchPHPVersion } ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments