Skip to content

Commit b02f079

Browse files
committed
fs: preserve raw filename bytes in glob buffer mode
Signed-off-by: jorge guerrero <grrr.jrg@gmail.com>
1 parent 6b5178f commit b02f079

File tree

3 files changed

+242
-55
lines changed

3 files changed

+242
-55
lines changed

doc/api/fs.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,9 @@ changes:
11151115
If a string array is provided, each string should be a glob pattern that
11161116
specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are
11171117
not supported.
1118+
* `encoding` {string} The path encoding. If set to `'buffer'`, the iterator
1119+
yields `Buffer` paths (or `Dirent` entries with `Buffer` names when
1120+
`withFileTypes` is `true`). **Default:** `'utf8'`.
11181121
* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents,
11191122
`false` otherwise. **Default:** `false`.
11201123
* Returns: {AsyncIterator} An AsyncIterator that yields the paths of files
@@ -3222,11 +3225,15 @@ changes:
32223225
* `exclude` {Function|string\[]} Function to filter out files/directories or a
32233226
list of glob patterns to be excluded. If a function is provided, return
32243227
`true` to exclude the item, `false` to include it. **Default:** `undefined`.
3228+
* `encoding` {string} The path encoding. If set to `'buffer'`, `matches`
3229+
contains `Buffer` paths (or `Dirent` entries with `Buffer` names when
3230+
`withFileTypes` is `true`). **Default:** `'utf8'`.
32253231
* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents,
32263232
`false` otherwise. **Default:** `false`.
32273233
32283234
* `callback` {Function}
32293235
* `err` {Error}
3236+
* `matches` {string\[]|Buffer\[]|fs.Dirent\[]}
32303237
32313238
* Retrieves the files matching the specified pattern.
32323239
@@ -5786,9 +5793,12 @@ changes:
57865793
* `exclude` {Function|string\[]} Function to filter out files/directories or a
57875794
list of glob patterns to be excluded. If a function is provided, return
57885795
`true` to exclude the item, `false` to include it. **Default:** `undefined`.
5796+
* `encoding` {string} The path encoding. If set to `'buffer'`, returns
5797+
`Buffer` paths (or `Dirent` entries with `Buffer` names when
5798+
`withFileTypes` is `true`). **Default:** `'utf8'`.
57895799
* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents,
57905800
`false` otherwise. **Default:** `false`.
5791-
* Returns: {string\[]} paths of files that match the pattern.
5801+
* Returns: {string\[]|Buffer\[]|fs.Dirent\[]} paths of files that match the pattern.
57925802
57935803
```mjs
57945804
import { globSync } from 'node:fs';

0 commit comments

Comments
 (0)