GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: correctly pass dirent to exclude `withFileTypes` · nodejs/node@b377b93

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/fs
    • glob.js
  • test/parallel
    • test-fs-glob.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/fs/glob.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/glob.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class Glob {
542542
const fromSymlink = pattern.symlinks.has(index);
543543

544544
if (current === lazyMinimatch().GLOBSTAR) {
545-
if (entry.name[0] === '.' || (this.#exclude && this.#exclude(entry.name))) {
545+
if (entry.name[0] === '.' || (this.#exclude && this.#exclude(this.#withFileTypes ? entry : entry.name))) {
546546
continue;
547547
}
548548
if (!fromSymlink && entry.isDirectory()) {
Collapse file

‎test/parallel/test-fs-glob.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-glob.mjs
+15-3Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,11 @@ describe('glob - withFileTypes', function() {
342342
const promisified = promisify(glob);
343343
for (const [pattern, expected] of Object.entries(patterns)) {
344344
test(pattern, async () => {
345-
const actual = await promisified(pattern, { cwd: fixtureDir, withFileTypes: true });
345+
const actual = await promisified(pattern, {
346+
cwd: fixtureDir,
347+
withFileTypes: true,
348+
exclude: (dirent) => assert.ok(dirent instanceof Dirent),
349+
});
346350
assertDirents(actual);
347351
const normalized = expected.filter(Boolean).map((item) => basename(item)).sort();
348352
assert.deepStrictEqual(actual.map((dirent) => dirent.name).sort(), normalized.sort());
@@ -353,7 +357,11 @@ describe('glob - withFileTypes', function() {
353357
describe('globSync - withFileTypes', function() {
354358
for (const [pattern, expected] of Object.entries(patterns)) {
355359
test(pattern, () => {
356-
const actual = globSync(pattern, { cwd: fixtureDir, withFileTypes: true });
360+
const actual = globSync(pattern, {
361+
cwd: fixtureDir,
362+
withFileTypes: true,
363+
exclude: (dirent) => assert.ok(dirent instanceof Dirent),
364+
});
357365
assertDirents(actual);
358366
const normalized = expected.filter(Boolean).map((item) => basename(item)).sort();
359367
assert.deepStrictEqual(actual.map((dirent) => dirent.name).sort(), normalized.sort());
@@ -365,7 +373,11 @@ describe('fsPromises glob - withFileTypes', function() {
365373
for (const [pattern, expected] of Object.entries(patterns)) {
366374
test(pattern, async () => {
367375
const actual = [];
368-
for await (const item of asyncGlob(pattern, { cwd: fixtureDir, withFileTypes: true })) actual.push(item);
376+
for await (const item of asyncGlob(pattern, {
377+
cwd: fixtureDir,
378+
withFileTypes: true,
379+
exclude: (dirent) => assert.ok(dirent instanceof Dirent),
380+
})) actual.push(item);
369381
assertDirents(actual);
370382
const normalized = expected.filter(Boolean).map((item) => basename(item)).sort();
371383
assert.deepStrictEqual(actual.map((dirent) => dirent.name).sort(), normalized.sort());

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.