use fstatSync instead of statSync
This commit is contained in:
parent
46db4850df
commit
dad3602d2b
2 changed files with 9 additions and 4 deletions
|
@ -147,9 +147,10 @@ export function fileExistsSync(path: string): boolean {
|
|||
throw new Error("Arg 'path' must not be empty")
|
||||
}
|
||||
|
||||
const fd = fs.openSync(path, 'r')
|
||||
let stats: fs.Stats
|
||||
try {
|
||||
stats = fs.statSync(path)
|
||||
stats = fs.fstatSync(fd)
|
||||
} catch (error) {
|
||||
if (hasErrorCode(error) && error.code === 'ENOENT') {
|
||||
return false
|
||||
|
@ -160,6 +161,8 @@ export function fileExistsSync(path: string): boolean {
|
|||
error
|
||||
)}`
|
||||
)
|
||||
} finally {
|
||||
fs.closeSync(fd)
|
||||
}
|
||||
|
||||
if (!stats.isDirectory()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue