Skip to content

Commit d1a967d

Browse files
committed
test
1 parent 00b1224 commit d1a967d

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

lib/utils/parser-config-resolver/should-use-flat-config.ts

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,35 @@ export function findFlatConfigFile(cwd: string) {
3838

3939
/** We used https://github.com/sindresorhus/find-up/blob/b733bb70d3aa21b22fa011be8089110d467c317f/index.js#L94 as a reference */
4040
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
5561
}
56-
}
5762

58-
if (directory === stopAt) {
59-
break
63+
directory = path.dirname(directory)
6064
}
6165

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
6371
}
64-
65-
return null
6672
}

0 commit comments

Comments
 (0)