Repository navigation
Conversation
2bc0ba6 to
bc710d9
Compare
iamstarkov
left a comment
There was a problem hiding this comment.
thank you, looks good to me
should it be mentioned for path.matchesGlob(path, pattern) as well?
|
I’ve added a note referencing |
bc710d9 to
45a5d32
Compare
|
and path.matchesGlob() does not support exclude? |
|
@mizulu @jasnell @lpinca |
|
@mag123c , I think so one can for example implement globing on an in memory file system ( list of paths ) This is out side the scope of this PR I might open an issue for feature request to improve on that. edit: #59015 |
| for await (const entry of glob('test/**/*.+(spec|test).js')) | ||
| console.log(entry); // Test files ending with .spec.js or .test.js |
There was a problem hiding this comment.
This will match foo.spectest.js, bar.testtesttesttestspecttest.js, etc.
Seems like a bad example of this pattern type?
| * `callback` {Function} | ||
| * `err` {Error} | ||
| * `matches` {string\[]|Dirent\[]} An array of paths or Dirent objects that |
There was a problem hiding this comment.
Are returned paths relative to options.cwd or absolute?
Are they normalized to the conventions of the current platform or always using / as the directory separator, consistent with how globs are specified?
|
@dmichon-msft
|
236358a to
da0b8e0
Compare
da0b8e0 to
cf75289
Compare
|
This PR unfortunately seems to have stalled somewhat? Found it looking for more docs on |
e2d9fb9 to
4cc26f6
Compare
|
@louwers Thanks for the review! I've addressed all your feedback. |
d66b457 to
26df356
Compare
26df356 to
92fb0eb
Compare
92fb0eb to
3756192
Compare
The fs.glob API was marked stable in v24 but the pattern parameter lacked any description of supported syntax. Add a pattern syntax reference table, platform behavior notes, a cross-reference to path.matchesGlob(), and an Array.fromAsync example. Also add pattern syntax cross-references from fs.glob() (callback) and fs.globSync(). Refs: nodejs#58981 Continues the work from nodejs#58988
3756192 to
d6c0b14
Compare
|
Rebased onto main. The conflict was with the While resolving it I also corrected one bullet that had gone stale in the meantime: the "Platform Considerations" list claimed symbolic links are always followed, which is no longer accurate now that |
| When `followSymlinks` is enabled, detected symbolic link cycles are not | ||
| traversed recursively. | ||
|
|
||
| #### Pattern Syntax |
There was a problem hiding this comment.
Can we defer to glob(7) or POSIX 2.14?
Rather than maintain this evolving(?) syntax?
There was a problem hiding this comment.
*, ?, [abc] and the / + leading-dot rules are all in glob(7) and we match them, so I'll link out instead of listing those here. doc/api/test.md already does that.
The rest isn't covered by either spec, though. **, {a,b}, +(...)/!(...) and [^abc] aren't in POSIX 2.14 or glob(7); they come from the vendored minimatch. POSIX actually says a bracket expression starting with ^ is unspecified. 2.14.3 also requires the result to be "sorted according to the collating sequence in effect in the current locale", and fs.glob() doesn't sort at all, so linking there would imply something we don't guarantee.
So, glob(7) for the basics, one small table for the extensions, and a line saying results aren't sorted. Is that okay?
|
Friendly ping, this has been sitting since July. @avivkeller @lpinca anything left blocking this? Would be great to get this closed |
|
Two small things on the extended glob table:
|
|
@vigilantee Thanks, both points were right. I confirmed the behavior locally with
|
`fs.glob()`, `fs.globSync()` and `fsPromises.glob()` now link to the shared "Glob patterns" section for pattern syntax, but still leave the `pattern` argument undescribed and say little about what they return. Describe the `pattern` argument, document that results are Dirents when `withFileTypes` is set, including the `fs.glob()` callback's `matches` argument and the `fs.globSync()` return type, and explain that paths are relative to `cwd` with the platform separator unless the pattern is absolute. Add an `Array.fromAsync()` example for collecting matches. Signed-off-by: mag123c <diehreo@gmail.com>
77003f3 to
2838ba3
Compare
#65392 added a shared "Glob patterns" section to
fs.mdand linked it fromfs.glob(),fs.globSync()andfsPromises.glob(), which covers the pattern syntax this PR first set out to document. This PR now fills in what is still missing around it.patternargument: described on all three APIs.fsPromises.glob()andfs.globSync()now say they producefs.Direntobjects whenwithFileTypesistrue, and thefs.glob()callback documents itsmatchesargument.cwdwith the platform separator, or absolute when the pattern is absolute (seetest/parallel/test-fs-glob.mjs).fs.glob()andfs.globSync()point to this.Array.fromAsync().fs.glob()parameter list are removed.Fixes: #58981