Skip to content

Commit 4744070

Browse files
authored
fs: add followSymlinks option to glob
PR-URL: #62695 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent 8176c2c commit 4744070

3 files changed

Lines changed: 308 additions & 28 deletions

File tree

doc/api/fs.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,9 @@ behavior is similar to `cp dir1/ dir2/`.
13511351
<!-- YAML
13521352
added: v22.0.0
13531353
changes:
1354+
- version: REPLACEME
1355+
pr-url: https://github.com/nodejs/node/pull/62695
1356+
description: Add support for the `followSymlinks` option.
13541357
- version:
13551358
- v24.1.0
13561359
- v22.17.0
@@ -1380,11 +1383,16 @@ changes:
13801383
If a string array is provided, each string should be a glob pattern that
13811384
specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are
13821385
not supported.
1386+
* `followSymlinks` {boolean} When `true`, symbolic links to directories are
1387+
followed while expanding `**` patterns. **Default:** `false`.
13831388
* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents,
13841389
`false` otherwise. **Default:** `false`.
13851390
* Returns: {AsyncIterator} An AsyncIterator that yields the paths of files
13861391
that match the pattern.
13871392
1393+
When `followSymlinks` is enabled, detected symbolic link cycles are not
1394+
traversed recursively.
1395+
13881396
```mjs
13891397
import { glob } from 'node:fs/promises';
13901398

@@ -3464,6 +3472,9 @@ descriptor. See [`fs.utimes()`][].
34643472
<!-- YAML
34653473
added: v22.0.0
34663474
changes:
3475+
- version: REPLACEME
3476+
pr-url: https://github.com/nodejs/node/pull/62695
3477+
description: Add support for the `followSymlinks` option.
34673478
- version:
34683479
- v24.1.0
34693480
- v22.17.0
@@ -3491,6 +3502,8 @@ changes:
34913502
* `exclude` {Function|string\[]} Function to filter out files/directories or a
34923503
list of glob patterns to be excluded. If a function is provided, return
34933504
`true` to exclude the item, `false` to include it. **Default:** `undefined`.
3505+
* `followSymlinks` {boolean} When `true`, symbolic links to directories are
3506+
followed while expanding `**` patterns. **Default:** `false`.
34943507
* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents,
34953508
`false` otherwise. **Default:** `false`.
34963509
@@ -3499,6 +3512,9 @@ changes:
34993512
35003513
* Retrieves the files matching the specified pattern.
35013514
3515+
When `followSymlinks` is enabled, detected symbolic link cycles are not
3516+
traversed recursively.
3517+
35023518
```mjs
35033519
import { glob } from 'node:fs';
35043520
@@ -6038,6 +6054,9 @@ Synchronous version of [`fs.futimes()`][]. Returns `undefined`.
60386054
<!-- YAML
60396055
added: v22.0.0
60406056
changes:
6057+
- version: REPLACEME
6058+
pr-url: https://github.com/nodejs/node/pull/62695
6059+
description: Add support for the `followSymlinks` option.
60416060
- version:
60426061
- v24.1.0
60436062
- v22.17.0
@@ -6064,10 +6083,15 @@ changes:
60646083
* `exclude` {Function|string\[]} Function to filter out files/directories or a
60656084
list of glob patterns to be excluded. If a function is provided, return
60666085
`true` to exclude the item, `false` to include it. **Default:** `undefined`.
6086+
* `followSymlinks` {boolean} When `true`, symbolic links to directories are
6087+
followed while expanding `**` patterns. **Default:** `false`.
60676088
* `withFileTypes` {boolean} `true` if the glob should return paths as Dirents,
60686089
`false` otherwise. **Default:** `false`.
60696090
* Returns: {string\[]} paths of files that match the pattern.
60706091
6092+
When `followSymlinks` is enabled, detected symbolic link cycles are not
6093+
traversed recursively.
6094+
60716095
```mjs
60726096
import { globSync } from 'node:fs';
60736097

0 commit comments

Comments
 (0)