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');
11
11
function findPHPVMRCFile ( startDir = process . cwd ( ) ) {
12
12
let currentDir = startDir ;
13
13
14
- while ( currentDir !== '/' ) {
14
+ while ( true ) {
15
15
const phpvmrcPath = path . join ( currentDir , '.phpvmrc' ) ;
16
16
if ( fs . existsSync ( phpvmrcPath ) ) {
17
17
return phpvmrcPath ;
18
18
}
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 ;
20
24
}
21
25
22
26
return null ;
@@ -41,10 +45,10 @@ async function autoSwitchPHPVersion() {
41
45
} catch ( error ) {
42
46
console . error ( `Failed to switch to PHP ${ version } : ${ error . message } ` ) ;
43
47
}
44
- } else {
45
- // Silent if no .phpvmrc file is found
46
- return ;
47
48
}
49
+
50
+ // Silent return when no .phpvmrc is found
51
+ return ;
48
52
}
49
53
50
54
module . exports = { findPHPVMRCFile, autoSwitchPHPVersion } ;
You can’t perform that action at this time.
0 commit comments