Skip to content

Commit a45c1aa

Browse files
committed
doc: fix mode and flags being mistaken in fs
Multiple `fs` functions have a `mode` and or `flag` option. In some cases those have been mistaken and named wrongly. All of those faulty entries have been fixed. Besides that some indentation is also aligned with the rest of the document. PR-URL: #27044 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent af5ddf2 commit a45c1aa

File tree

1 file changed

+46
-47
lines changed

1 file changed

+46
-47
lines changed

doc/api/fs.md

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,14 +1556,14 @@ Returns an object containing commonly used constants for file system
15561556
operations. The specific constants currently defined are described in
15571557
[FS Constants][].
15581558

1559-
## `fs.copyFile(src, dest[, flags], callback)`
1559+
## `fs.copyFile(src, dest[, mode], callback)`
15601560
<!-- YAML
15611561
added: v8.5.0
15621562
-->
15631563

15641564
* `src` {string|Buffer|URL} source filename to copy
15651565
* `dest` {string|Buffer|URL} destination filename of the copy operation
1566-
* `flags` {number} modifiers for copy operation. **Default:** `0`.
1566+
* `mode` {integer} modifiers for copy operation. **Default:** `0`.
15671567
* `callback` {Function}
15681568

15691569
Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
@@ -1572,7 +1572,7 @@ callback function. Node.js makes no guarantees about the atomicity of the copy
15721572
operation. If an error occurs after the destination file has been opened for
15731573
writing, Node.js will attempt to remove the destination.
15741574

1575-
`flags` is an optional integer that specifies the behavior
1575+
`mode` is an optional integer that specifies the behavior
15761576
of the copy operation. It is possible to create a mask consisting of the bitwise
15771577
OR of two or more values (e.g.
15781578
`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
@@ -1596,7 +1596,7 @@ fs.copyFile('source.txt', 'destination.txt', (err) => {
15961596
});
15971597
```
15981598

1599-
If the third argument is a number, then it specifies `flags`:
1599+
If the third argument is a number, then it specifies `mode`:
16001600

16011601
```js
16021602
const fs = require('fs');
@@ -1606,21 +1606,21 @@ const { COPYFILE_EXCL } = fs.constants;
16061606
fs.copyFile('source.txt', 'destination.txt', COPYFILE_EXCL, callback);
16071607
```
16081608

1609-
## `fs.copyFileSync(src, dest[, flags])`
1609+
## `fs.copyFileSync(src, dest[, mode])`
16101610
<!-- YAML
16111611
added: v8.5.0
16121612
-->
16131613

16141614
* `src` {string|Buffer|URL} source filename to copy
16151615
* `dest` {string|Buffer|URL} destination filename of the copy operation
1616-
* `flags` {number} modifiers for copy operation. **Default:** `0`.
1616+
* `mode` {integer} modifiers for copy operation. **Default:** `0`.
16171617

16181618
Synchronously copies `src` to `dest`. By default, `dest` is overwritten if it
16191619
already exists. Returns `undefined`. Node.js makes no guarantees about the
16201620
atomicity of the copy operation. If an error occurs after the destination file
16211621
has been opened for writing, Node.js will attempt to remove the destination.
16221622

1623-
`flags` is an optional integer that specifies the behavior
1623+
`mode` is an optional integer that specifies the behavior
16241624
of the copy operation. It is possible to create a mask consisting of the bitwise
16251625
OR of two or more values (e.g.
16261626
`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
@@ -1642,7 +1642,7 @@ fs.copyFileSync('source.txt', 'destination.txt');
16421642
console.log('source.txt was copied to destination.txt');
16431643
```
16441644

1645-
If the third argument is a number, then it specifies `flags`:
1645+
If the third argument is a number, then it specifies `mode`:
16461646

16471647
```js
16481648
const fs = require('fs');
@@ -1796,12 +1796,11 @@ changes:
17961796
* `fs` {Object|null} **Default:** `null`
17971797
* Returns: {fs.WriteStream} See [Writable Stream][].
17981798

1799-
`options` may also include a `start` option to allow writing data at
1800-
some position past the beginning of the file, allowed values are in the
1801-
[0, [`Number.MAX_SAFE_INTEGER`][]] range. Modifying a file rather
1802-
than replacing it may require a `flags` mode of `r+` rather than the
1803-
default mode `w`. The `encoding` can be any one of those accepted by
1804-
[`Buffer`][].
1799+
`options` may also include a `start` option to allow writing data at some
1800+
position past the beginning of the file, allowed values are in the
1801+
[0, [`Number.MAX_SAFE_INTEGER`][]] range. Modifying a file rather than replacing
1802+
it may require the `flags` option to be set to `r+` rather than the default `w`.
1803+
The `encoding` can be any one of those accepted by [`Buffer`][].
18051804

18061805
If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`
18071806
the file descriptor will be closed automatically. If `autoClose` is false,
@@ -2466,7 +2465,7 @@ changes:
24662465
Asynchronously creates a directory. No arguments other than a possible exception
24672466
are given to the completion callback.
24682467

2469-
The optional `options` argument can be an integer specifying mode (permission
2468+
The optional `options` argument can be an integer specifying `mode` (permission
24702469
and sticky bits), or an object with a `mode` property and a `recursive`
24712470
property indicating whether parent folders should be created. Calling
24722471
`fs.mkdir()` when `path` is a directory that exists results in an error only
@@ -2617,7 +2616,7 @@ changes:
26172616
description: The `flags` argument is now optional and defaults to `'r'`.
26182617
- version: v9.9.0
26192618
pr-url: https://github.com/nodejs/node/pull/18801
2620-
description: The `as` and `as+` modes are supported now.
2619+
description: The `as` and `as+` flags are supported now.
26212620
- version: v7.6.0
26222621
pr-url: https://github.com/nodejs/node/pull/10739
26232622
description: The `path` parameter can be a WHATWG `URL` object using `file:`
@@ -2709,7 +2708,7 @@ changes:
27092708
description: The `flags` argument is now optional and defaults to `'r'`.
27102709
- version: v9.9.0
27112710
pr-url: https://github.com/nodejs/node/pull/18801
2712-
description: The `as` and `as+` modes are supported now.
2711+
description: The `as` and `as+` flags are supported now.
27132712
- version: v7.6.0
27142713
pr-url: https://github.com/nodejs/node/pull/10739
27152714
description: The `path` parameter can be a WHATWG `URL` object using `file:`
@@ -3276,16 +3275,16 @@ changes:
32763275
* `path` {string|Buffer|URL}
32773276
* `options` {Object}
32783277
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
3279-
`EPERM` error is encountered, Node.js will retry the operation with a linear
3280-
backoff wait of `retryDelay` ms longer on each try. This option represents the
3281-
number of retries. This option is ignored if the `recursive` option is not
3282-
`true`. **Default:** `0`.
3278+
`EPERM` error is encountered, Node.js will retry the operation with a linear
3279+
backoff wait of `retryDelay` ms longer on each try. This option represents
3280+
the number of retries. This option is ignored if the `recursive` option is
3281+
not `true`. **Default:** `0`.
32833282
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
3284-
recursive mode, errors are not reported if `path` does not exist, and
3285-
operations are retried on failure. **Default:** `false`.
3283+
recursive mode, errors are not reported if `path` does not exist, and
3284+
operations are retried on failure. **Default:** `false`.
32863285
* `retryDelay` {integer} The amount of time in milliseconds to wait between
3287-
retries. This option is ignored if the `recursive` option is not `true`.
3288-
**Default:** `100`.
3286+
retries. This option is ignored if the `recursive` option is not `true`.
3287+
**Default:** `100`.
32893288
* `callback` {Function}
32903289
* `err` {Error}
32913290

@@ -3321,16 +3320,16 @@ changes:
33213320
* `path` {string|Buffer|URL}
33223321
* `options` {Object}
33233322
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
3324-
`EPERM` error is encountered, Node.js will retry the operation with a linear
3325-
backoff wait of `retryDelay` ms longer on each try. This option represents the
3326-
number of retries. This option is ignored if the `recursive` option is not
3327-
`true`. **Default:** `0`.
3323+
`EPERM` error is encountered, Node.js will retry the operation with a linear
3324+
backoff wait of `retryDelay` ms longer on each try. This option represents
3325+
the number of retries. This option is ignored if the `recursive` option is
3326+
not `true`. **Default:** `0`.
33283327
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
3329-
recursive mode, errors are not reported if `path` does not exist, and
3330-
operations are retried on failure. **Default:** `false`.
3328+
recursive mode, errors are not reported if `path` does not exist, and
3329+
operations are retried on failure. **Default:** `false`.
33313330
* `retryDelay` {integer} The amount of time in milliseconds to wait between
3332-
retries. This option is ignored if the `recursive` option is not `true`.
3333-
**Default:** `100`.
3331+
retries. This option is ignored if the `recursive` option is not `true`.
3332+
**Default:** `100`.
33343333

33353334
Synchronous rmdir(2). Returns `undefined`.
33363335

@@ -4687,14 +4686,14 @@ added: v10.0.0
46874686
Changes the ownership of a file then resolves the `Promise` with no arguments
46884687
upon success.
46894688

4690-
### `fsPromises.copyFile(src, dest[, flags])`
4689+
### `fsPromises.copyFile(src, dest[, mode])`
46914690
<!-- YAML
46924691
added: v10.0.0
46934692
-->
46944693

46954694
* `src` {string|Buffer|URL} source filename to copy
46964695
* `dest` {string|Buffer|URL} destination filename of the copy operation
4697-
* `flags` {number} modifiers for copy operation. **Default:** `0`.
4696+
* `mode` {integer} modifiers for copy operation. **Default:** `0`.
46984697
* Returns: {Promise}
46994698

47004699
Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
@@ -4704,7 +4703,7 @@ Node.js makes no guarantees about the atomicity of the copy operation. If an
47044703
error occurs after the destination file has been opened for writing, Node.js
47054704
will attempt to remove the destination.
47064705

4707-
`flags` is an optional integer that specifies the behavior
4706+
`mode` is an optional integer that specifies the behavior
47084707
of the copy operation. It is possible to create a mask consisting of the bitwise
47094708
OR of two or more values (e.g.
47104709
`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
@@ -4727,7 +4726,7 @@ fsPromises.copyFile('source.txt', 'destination.txt')
47274726
.catch(() => console.log('The file could not be copied'));
47284727
```
47294728

4730-
If the third argument is a number, then it specifies `flags`:
4729+
If the third argument is a number, then it specifies `mode`:
47314730

47324731
```js
47334732
const fs = require('fs');
@@ -4813,7 +4812,7 @@ added: v10.0.0
48134812
Asynchronously creates a directory then resolves the `Promise` with no
48144813
arguments upon success.
48154814

4816-
The optional `options` argument can be an integer specifying mode (permission
4815+
The optional `options` argument can be an integer specifying `mode` (permission
48174816
and sticky bits), or an object with a `mode` property and a `recursive`
48184817
property indicating whether parent folders should be created. Calling
48194818
`fsPromises.mkdir()` when `path` is a directory that exists results in a
@@ -5044,16 +5043,16 @@ changes:
50445043
* `path` {string|Buffer|URL}
50455044
* `options` {Object}
50465045
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
5047-
`EPERM` error is encountered, Node.js will retry the operation with a linear
5048-
backoff wait of `retryDelay` ms longer on each try. This option represents the
5049-
number of retries. This option is ignored if the `recursive` option is not
5050-
`true`. **Default:** `0`.
5046+
`EPERM` error is encountered, Node.js will retry the operation with a linear
5047+
backoff wait of `retryDelay` ms longer on each try. This option represents
5048+
the number of retries. This option is ignored if the `recursive` option is
5049+
not `true`. **Default:** `0`.
50515050
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
5052-
recursive mode, errors are not reported if `path` does not exist, and
5053-
operations are retried on failure. **Default:** `false`.
5051+
recursive mode, errors are not reported if `path` does not exist, and
5052+
operations are retried on failure. **Default:** `false`.
50545053
* `retryDelay` {integer} The amount of time in milliseconds to wait between
5055-
retries. This option is ignored if the `recursive` option is not `true`.
5056-
**Default:** `100`.
5054+
retries. This option is ignored if the `recursive` option is not `true`.
5055+
**Default:** `100`.
50575056
* Returns: {Promise}
50585057

50595058
Removes the directory identified by `path` then resolves the `Promise` with
@@ -5541,7 +5540,7 @@ the file contents.
55415540
[`fs.access()`]: #fs_fs_access_path_mode_callback
55425541
[`fs.chmod()`]: #fs_fs_chmod_path_mode_callback
55435542
[`fs.chown()`]: #fs_fs_chown_path_uid_gid_callback
5544-
[`fs.copyFile()`]: #fs_fs_copyfile_src_dest_flags_callback
5543+
[`fs.copyFile()`]: #fs_fs_copyfile_src_dest_mode_callback
55455544
[`fs.createWriteStream()`]: #fs_fs_createwritestream_path_options
55465545
[`fs.exists()`]: fs.html#fs_fs_exists_path_callback
55475546
[`fs.fstat()`]: #fs_fs_fstat_fd_options_callback

0 commit comments

Comments
 (0)