@@ -1069,6 +1069,38 @@ including subdirectories and files.
1069
1069
When copying a directory to another directory, globs are not supported and
1070
1070
behavior is similar to ` cp dir1/ dir2/ ` .
1071
1071
1072
+ ### ` fsPromises .glob (pattern[, options])`
1073
+
1074
+ <!-- YAML
1075
+ added: REPLACEME
1076
+ -->
1077
+
1078
+ > Stability: 1 - Experimental
1079
+
1080
+ * ` pattern` {string|string\[ ]}
1081
+ * ` options` {Object}
1082
+ * ` cwd` {string} current working directory. **Default:** ` process .cwd ()`
1083
+ * ` exclude` {Function} Function to filter out files/directories. Return
1084
+ ` true ` to exclude the item, ` false ` to include it. **Default:** ` undefined ` .
1085
+ * Returns: {AsyncIterator} An AsyncIterator that yields the paths of files
1086
+ that match the pattern.
1087
+
1088
+ ` ` ` mjs
1089
+ import { glob } from ' node:fs/promises' ;
1090
+
1091
+ for await (const entry of glob (' **/*.js' ))
1092
+ console .log (entry);
1093
+ ` ` `
1094
+
1095
+ ` ` ` cjs
1096
+ const { glob } = require (' node:fs/promises' );
1097
+
1098
+ (async () => {
1099
+ for await (const entry of glob (' **/*.js' ))
1100
+ console .log (entry);
1101
+ })();
1102
+ ` ` `
1103
+
1072
1104
### ` fsPromises .lchmod (path, mode)`
1073
1105
1074
1106
<!-- YAML
@@ -3073,6 +3105,44 @@ changes:
3073
3105
Change the file system timestamps of the object referenced by the supplied file
3074
3106
descriptor. See [`fs.utimes()`][].
3075
3107
3108
+ ### `fs.glob(pattern[, options], callback)`
3109
+
3110
+ <!-- YAML
3111
+ added: REPLACEME
3112
+ -->
3113
+
3114
+ > Stability: 1 - Experimental
3115
+
3116
+ * `pattern` {string|string\[ ]}
3117
+
3118
+ * `options` {Object}
3119
+ * `cwd` {string} current working directory. **Default:** `process.cwd()`
3120
+ * `exclude` {Function} Function to filter out files/directories. Return
3121
+ `true` to exclude the item, `false` to include it. **Default:** `undefined`.
3122
+
3123
+ * `callback` {Function}
3124
+ * `err` {Error}
3125
+
3126
+ * Retrieves the files matching the specified pattern.
3127
+
3128
+ ```mjs
3129
+ import { glob } from 'node:fs';
3130
+
3131
+ glob('**/*.js', (err, matches) => {
3132
+ if (err) throw err;
3133
+ console.log(matches);
3134
+ });
3135
+ ```
3136
+
3137
+ ```cjs
3138
+ const { glob } = require('node:fs');
3139
+
3140
+ glob('**/*.js', (err, matches) => {
3141
+ if (err) throw err;
3142
+ console.log(matches);
3143
+ });
3144
+ ```
3145
+
3076
3146
### `fs.lchmod(path, mode, callback)`
3077
3147
3078
3148
<!-- YAML
@@ -5529,6 +5599,33 @@ changes:
5529
5599
5530
5600
Synchronous version of [` fs .futimes ()` ][]. Returns ` undefined ` .
5531
5601
5602
+ ### ` fs .globSync (pattern[, options])`
5603
+
5604
+ <!-- YAML
5605
+ added: REPLACEME
5606
+ -->
5607
+
5608
+ > Stability: 1 - Experimental
5609
+
5610
+ * ` pattern` {string|string\[ ]}
5611
+ * ` options` {Object}
5612
+ * ` cwd` {string} current working directory. **Default:** ` process .cwd ()`
5613
+ * ` exclude` {Function} Function to filter out files/directories. Return
5614
+ ` true ` to exclude the item, ` false ` to include it. **Default:** ` undefined ` .
5615
+ * Returns: {string\[ ]} paths of files that match the pattern.
5616
+
5617
+ ` ` ` mjs
5618
+ import { globSync } from ' node:fs' ;
5619
+
5620
+ console .log (globSync (' **/*.js' ));
5621
+ ` ` `
5622
+
5623
+ ` ` ` cjs
5624
+ const { globSync } = require (' node:fs' );
5625
+
5626
+ console .log (globSync (' **/*.js' ));
5627
+ ` ` `
5628
+
5532
5629
### ` fs .lchmodSync (path, mode)`
5533
5630
5534
5631
<!-- YAML
0 commit comments