File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -16,17 +16,28 @@ export function projectInfo(cwd: string) : ProjectInfo {
1616 : null
1717 if ( config ) return config
1818
19- const parentDir = path . dirname ( cwd )
19+ // Search for .sln or .slnx file by walking up the directory tree
2020 let slnDir = ''
21- let sln = fs . readdirSync ( cwd ) . find ( f => f . endsWith ( ".sln" ) || f . endsWith ( ".slnx" ) )
22- if ( sln ) {
23- slnDir = cwd
24- } else {
25- sln = fs . readdirSync ( parentDir ) . find ( f => f . endsWith ( ".sln" ) || f . endsWith ( ".slnx" ) )
26- if ( sln ) {
27- slnDir = parentDir
21+ let sln = ''
22+ let currentDir = cwd
23+ const root = path . parse ( currentDir ) . root
24+
25+ while ( currentDir !== root ) {
26+ try {
27+ const found = fs . readdirSync ( currentDir ) . find ( f => f . endsWith ( ".sln" ) || f . endsWith ( ".slnx" ) )
28+ if ( found ) {
29+ sln = found
30+ slnDir = currentDir
31+ break
32+ }
33+ } catch ( e ) {
34+ // ignore permission errors
2835 }
36+ const parentDir = path . dirname ( currentDir )
37+ if ( parentDir === currentDir ) break // reached root
38+ currentDir = parentDir
2939 }
40+
3041 if ( ! sln ) {
3142 return null
3243 }
You can’t perform that action at this time.
0 commit comments