fs: fix ENOTDIR in globSync when file is treated as dir · nodejs/node@bacba16 · GitHub
Skip to content

Commit bacba16

Browse files
Han5991aduh95
authored andcommitted
fs: fix ENOTDIR in globSync when file is treated as dir
`fs.globSync` failed with `ENOTDIR` when a path component in a glob pattern was a file but used as a directory (e.g., 'foo{,/bar}' when 'foo' is a file). This change aligns `getDirentSync` with the asynchronous `getDirent` by wrapping the `lstatSync` call in a `try-catch` block to safely return `null` on such errors. Fixes: #61257 PR-URL: #61259 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
1 parent 2423ecd commit bacba16

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

lib/internal/fs/glob.js

Lines changed: 4 additions & 2 deletions

test/parallel/test-fs-glob.mjs

Lines changed: 19 additions & 1 deletion

0 commit comments

Comments
 (0)