fs.statSync(fs.realpathSync()) for fileExistsSync
This commit is contained in:
parent
8e161f8241
commit
260c5e341d
@ -147,10 +147,9 @@ export function fileExistsSync(path: string): boolean {
|
|||||||
throw new Error("Arg 'path' must not be empty")
|
throw new Error("Arg 'path' must not be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
const fd = fs.openSync(path, 'r')
|
|
||||||
let stats: fs.Stats
|
let stats: fs.Stats
|
||||||
try {
|
try {
|
||||||
stats = fs.fstatSync(fd)
|
stats = fs.statSync(fs.realpathSync(path))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (hasErrorCode(error) && error.code === 'ENOENT') {
|
if (hasErrorCode(error) && error.code === 'ENOENT') {
|
||||||
return false
|
return false
|
||||||
@ -161,8 +160,6 @@ export function fileExistsSync(path: string): boolean {
|
|||||||
error
|
error
|
||||||
)}`
|
)}`
|
||||||
)
|
)
|
||||||
} finally {
|
|
||||||
fs.closeSync(fd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stats.isDirectory()) {
|
if (!stats.isDirectory()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user