Skip to content

Commit 2f1f738

Browse files
committed
fs: add followSymlinks option to glob
1 parent 449a93a commit 2f1f738

File tree

3 files changed

+306
-28
lines changed

3 files changed

+306
-28
lines changed

doc/api/fs.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,9 @@ behavior is similar to `cp dir1/ dir2/`.
13491349
<!-- YAML
13501350
added: v22.0.0
13511351
changes:
1352+
- version: REPLACEME
1353+
pr-url: REPLACEME
1354+
description: Add support for the `followSymlinks` option.
13521355
- version:
13531356
- v24.1.0
13541357
- v22.17.0
@@ -1378,11 +1381,16 @@ changes:
13781381
If a string array is provided, each string should be a glob pattern that
13791382
specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are
13801383
not supported.
1384+
* `followSymlinks` {boolean} When `true`, symbolic links to directories are
1385+
followed while expanding `**` patterns. **Default:** `false`.
13811386
* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents,
13821387
`false` otherwise. **Default:** `false`.
13831388
* Returns: {AsyncIterator} An AsyncIterator that yields the paths of files
13841389
that match the pattern.
13851390
1391+
When `followSymlinks` is enabled, detected symbolic link cycles are not
1392+
traversed recursively.
1393+
13861394
```mjs
13871395
import { glob } from 'node:fs/promises';
13881396

@@ -3462,6 +3470,9 @@ descriptor. See [`fs.utimes()`][].
34623470
<!-- YAML
34633471
added: v22.0.0
34643472
changes:
3473+
- version: REPLACEME
3474+
pr-url: REPLACEME
3475+
description: Add support for the `followSymlinks` option.
34653476
- version:
34663477
- v24.1.0
34673478
- v22.17.0
@@ -3489,6 +3500,8 @@ changes:
34893500
* `exclude` {Function|string\[]} Function to filter out files/directories or a
34903501
list of glob patterns to be excluded. If a function is provided, return
34913502
`true` to exclude the item, `false` to include it. **Default:** `undefined`.
3503+
* `followSymlinks` {boolean} When `true`, symbolic links to directories are
3504+
followed while expanding `**` patterns. **Default:** `false`.
34923505
* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents,
34933506
`false` otherwise. **Default:** `false`.
34943507
@@ -3497,6 +3510,9 @@ changes:
34973510
34983511
* Retrieves the files matching the specified pattern.
34993512
3513+
When `followSymlinks` is enabled, detected symbolic link cycles are not
3514+
traversed recursively.
3515+
35003516
```mjs
35013517
import { glob } from 'node:fs';
35023518
@@ -6031,6 +6047,9 @@ Synchronous version of [`fs.futimes()`][]. Returns `undefined`.
60316047
<!-- YAML
60326048
added: v22.0.0
60336049
changes:
6050+
- version: REPLACEME
6051+
pr-url: REPLACEME
6052+
description: Add support for the `followSymlinks` option.
60346053
- version:
60356054
- v24.1.0
60366055
- v22.17.0
@@ -6057,10 +6076,15 @@ changes:
60576076
* `exclude` {Function|string\[]} Function to filter out files/directories or a
60586077
list of glob patterns to be excluded. If a function is provided, return
60596078
`true` to exclude the item, `false` to include it. **Default:** `undefined`.
6079+
* `followSymlinks` {boolean} When `true`, symbolic links to directories are
6080+
followed while expanding `**` patterns. **Default:** `false`.
60606081
* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents,
60616082
`false` otherwise. **Default:** `false`.
60626083
* Returns: {string\[]} paths of files that match the pattern.
60636084
6085+
When `followSymlinks` is enabled, detected symbolic link cycles are not
6086+
traversed recursively.
6087+
60646088
```mjs
60656089
import { globSync } from 'node:fs';
60666090

0 commit comments

Comments
 (0)