@@ -38,29 +38,35 @@ export function findFlatConfigFile(cwd: string) {
38
38
39
39
/** We used https://github.com/sindresorhus/find-up/blob/b733bb70d3aa21b22fa011be8089110d467c317f/index.js#L94 as a reference */
40
40
function findUp ( names : string [ ] , options : { cwd : string } ) {
41
- let directory = path . resolve ( options . cwd )
42
- const { root } = path . parse ( directory )
43
- const stopAt = path . resolve ( directory , root )
44
- // eslint-disable-next-line no-constant-condition -- ignore
45
- while ( true ) {
46
- for ( const name of names ) {
47
- const target = path . resolve ( directory , name )
48
- const stat = fs . existsSync ( target )
49
- ? fs . statSync ( target , {
50
- throwIfNoEntry : false
51
- } )
52
- : null
53
- if ( stat ?. isFile ( ) ) {
54
- return target
41
+ try {
42
+ let directory = path . resolve ( options . cwd )
43
+ const { root } = path . parse ( directory )
44
+ const stopAt = path . resolve ( directory , root )
45
+ // eslint-disable-next-line no-constant-condition -- ignore
46
+ while ( true ) {
47
+ for ( const name of names ) {
48
+ const target = path . resolve ( directory , name )
49
+ const stat = fs . existsSync ( target )
50
+ ? fs . statSync ( target , {
51
+ throwIfNoEntry : false
52
+ } )
53
+ : null
54
+ if ( stat ?. isFile ( ) ) {
55
+ return target
56
+ }
57
+ }
58
+
59
+ if ( directory === stopAt ) {
60
+ break
55
61
}
56
- }
57
62
58
- if ( directory === stopAt ) {
59
- break
63
+ directory = path . dirname ( directory )
60
64
}
61
65
62
- directory = path . dirname ( directory )
66
+ return null
67
+ } catch ( e ) {
68
+ console . log ( 'Error in should-use-flat-config' )
69
+ console . error ( e )
70
+ throw e
63
71
}
64
-
65
- return null
66
72
}
0 commit comments