Skip to content

Commit 3a8efcd

Browse files
committed
fs: fix glob lint issues
1 parent 2f1f738 commit 3a8efcd

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

doc/api/fs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ behavior is similar to `cp dir1/ dir2/`.
13501350
added: v22.0.0
13511351
changes:
13521352
- version: REPLACEME
1353-
pr-url: REPLACEME
1353+
pr-url: https://github.com/nodejs/node/pull/62695
13541354
description: Add support for the `followSymlinks` option.
13551355
- version:
13561356
- v24.1.0
@@ -3471,7 +3471,7 @@ descriptor. See [`fs.utimes()`][].
34713471
added: v22.0.0
34723472
changes:
34733473
- version: REPLACEME
3474-
pr-url: REPLACEME
3474+
pr-url: https://github.com/nodejs/node/pull/62695
34753475
description: Add support for the `followSymlinks` option.
34763476
- version:
34773477
- v24.1.0
@@ -6048,7 +6048,7 @@ Synchronous version of [`fs.futimes()`][]. Returns `undefined`.
60486048
added: v22.0.0
60496049
changes:
60506050
- version: REPLACEME
6051-
pr-url: REPLACEME
6051+
pr-url: https://github.com/nodejs/node/pull/62695
60526052
description: Add support for the `followSymlinks` option.
60536053
- version:
60546054
- v24.1.0

lib/internal/fs/glob.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,9 @@ class Glob {
785785
const entryFullpath = join(fullpath, entry.name);
786786
this.#cache.addToStatCache(entryFullpath, entry);
787787
const entryIsDirectory = entry.isDirectory() ||
788-
(this.#followSymlinks && entry.isSymbolicLink() && !!(await this.#cache.followStat(entryFullpath))?.isDirectory());
788+
(this.#followSymlinks &&
789+
entry.isSymbolicLink() &&
790+
!!(await this.#cache.followStat(entryFullpath))?.isDirectory());
789791

790792
const subPatterns = new SafeSet();
791793
const nSymlinks = new SafeSet();

test/parallel/test-fs-glob.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ const followSymlinkExpectedWithFollow = [
551551
'follow/link/file.txt'.replaceAll('/', sep),
552552
].sort();
553553

554-
const assertNoNestedCycleMatches = (matches) => {
555-
assert.ok(!matches.some((match) => match.startsWith(`follow${sep}cycle${sep}`)), matches.join('\n'));
554+
const getNestedCycleMatches = (matches) => {
555+
return matches.filter((match) => match.startsWith(`follow${sep}cycle${sep}`));
556556
};
557557

558558
describe('glob - followSymlinks', function() {
@@ -569,7 +569,7 @@ describe('glob - followSymlinks', function() {
569569
followSymlinks: true,
570570
})).sort();
571571
assert.deepStrictEqual(actual, followSymlinkExpectedWithFollow);
572-
assertNoNestedCycleMatches(actual);
572+
assert.deepStrictEqual(getNestedCycleMatches(actual), []);
573573
});
574574
});
575575

@@ -596,7 +596,7 @@ describe('globSync - followSymlinks', function() {
596596
followSymlinks: true,
597597
}).sort();
598598
assert.deepStrictEqual(actual, followSymlinkExpectedWithFollow);
599-
assertNoNestedCycleMatches(actual);
599+
assert.deepStrictEqual(getNestedCycleMatches(actual), []);
600600
});
601601

602602
test('supports withFileTypes when following symlinked directories', () => {
@@ -608,7 +608,7 @@ describe('globSync - followSymlinks', function() {
608608
assertDirents(actual);
609609
const normalized = actual.map(normalizeDirent).sort();
610610
assert.deepStrictEqual(normalized, followSymlinkExpectedWithFollow);
611-
assertNoNestedCycleMatches(normalized);
611+
assert.deepStrictEqual(getNestedCycleMatches(normalized), []);
612612
});
613613
});
614614

@@ -628,7 +628,7 @@ describe('fsPromises glob - followSymlinks', function() {
628628
})) actual.push(item);
629629
actual.sort();
630630
assert.deepStrictEqual(actual, followSymlinkExpectedWithFollow);
631-
assertNoNestedCycleMatches(actual);
631+
assert.deepStrictEqual(getNestedCycleMatches(actual), []);
632632
});
633633
});
634634

0 commit comments

Comments
 (0)