Commit bacba16
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 bacba16Copy full SHA for bacba16
2 files changed
+23-3Lines changed: 23 additions & 3 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- lib/internal/fs
- test/parallel
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+4-2Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
65 | 65 | |
66 | 66 | |
67 | 67 | |
68 | | - |
69 | | - |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
70 | 72 | |
71 | 73 | |
72 | 74 | |
|
Collapse file
test/parallel/test-fs-glob.mjs
Copy file name to clipboardExpand all lines: test/parallel/test-fs-glob.mjs+19-1Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
2 | 2 | |
3 | 3 | |
4 | 4 | |
5 | | - |
| 5 | + |
6 | 6 | |
7 | 7 | |
8 | 8 | |
| ||
543 | 543 | |
544 | 544 | |
545 | 545 | |
| 546 | + |
| 547 | + |
| 548 | + |
| 549 | + |
| 550 | + |
| 551 | + |
| 552 | + |
| 553 | + |
| 554 | + |
| 555 | + |
| 556 | + |
| 557 | + |
| 558 | + |
| 559 | + |
| 560 | + |
| 561 | + |
| 562 | + |
| 563 | + |
0 commit comments