Skip to content

Commit 391c420

Browse files
TrottMylesBorins
authored andcommitted
doc: synchronize argument names for appendFile()
The documentation used `file` for the first argument to `appendFile()` functions. However, the code and (more importantly) thrown errors referred to it as `path`. The latter is especially important because context is not provided. So you're looking for a function that takes `path` but that string doesn't appear in your code *or* in the documentation. It's not until the end user looks at the source code of Node.js that they can figure out what's going on. This is why it is important that the names of variables in the documentation match that in the code. If we want to change this to `file`, then that's OK, but we need to do it in the source code and error messages too, not just in the docs. Changing the docs is the smallest change to synchronize everything so that's what this change does. PR-URL: #20489 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 8b17e7a commit 391c420

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

doc/api/fs.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ try {
892892
}
893893
```
894894

895-
## fs.appendFile(file, data[, options], callback)
895+
## fs.appendFile(path, data[, options], callback)
896896
<!-- YAML
897897
added: v0.6.7
898898
changes:
@@ -912,7 +912,7 @@ changes:
912912
description: The `file` parameter can be a file descriptor now.
913913
-->
914914

915-
* `file` {string|Buffer|URL|number} filename or file descriptor
915+
* `path` {string|Buffer|URL|number} filename or file descriptor
916916
* `data` {string|Buffer}
917917
* `options` {Object|string}
918918
* `encoding` {string|null} **Default:** `'utf8'`
@@ -939,7 +939,7 @@ If `options` is a string, then it specifies the encoding. Example:
939939
fs.appendFile('message.txt', 'data to append', 'utf8', callback);
940940
```
941941

942-
The `file` may be specified as a numeric file descriptor that has been opened
942+
The `path` may be specified as a numeric file descriptor that has been opened
943943
for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
944944
not be closed automatically.
945945

@@ -955,7 +955,7 @@ fs.open('message.txt', 'a', (err, fd) => {
955955
});
956956
```
957957

958-
## fs.appendFileSync(file, data[, options])
958+
## fs.appendFileSync(path, data[, options])
959959
<!-- YAML
960960
added: v0.6.7
961961
changes:
@@ -967,7 +967,7 @@ changes:
967967
description: The `file` parameter can be a file descriptor now.
968968
-->
969969

970-
* `file` {string|Buffer|URL|number} filename or file descriptor
970+
* `path` {string|Buffer|URL|number} filename or file descriptor
971971
* `data` {string|Buffer}
972972
* `options` {Object|string}
973973
* `encoding` {string|null} **Default:** `'utf8'`
@@ -994,7 +994,7 @@ If `options` is a string, then it specifies the encoding. Example:
994994
fs.appendFileSync('message.txt', 'data to append', 'utf8');
995995
```
996996

997-
The `file` may be specified as a numeric file descriptor that has been opened
997+
The `path` may be specified as a numeric file descriptor that has been opened
998998
for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
999999
not be closed automatically.
10001000

@@ -3687,12 +3687,12 @@ condition, since other processes may change the file's state between the two
36873687
calls. Instead, user code should open/read/write the file directly and handle
36883688
the error raised if the file is not accessible.
36893689

3690-
### fsPromises.appendFile(file, data[, options])
3690+
### fsPromises.appendFile(path, data[, options])
36913691
<!-- YAML
36923692
added: v10.0.0
36933693
-->
36943694

3695-
* `file` {string|Buffer|URL|FileHandle} filename or `FileHandle`
3695+
* `path` {string|Buffer|URL|FileHandle} filename or `FileHandle`
36963696
* `data` {string|Buffer}
36973697
* `options` {Object|string}
36983698
* `encoding` {string|null} **Default:** `'utf8'`
@@ -3706,7 +3706,7 @@ resolved with no arguments upon success.
37063706

37073707
If `options` is a string, then it specifies the encoding.
37083708

3709-
The `file` may be specified as a `FileHandle` that has been opened
3709+
The `path` may be specified as a `FileHandle` that has been opened
37103710
for appending (using `fsPromises.open()`).
37113711

37123712
### fsPromises.chmod(path, mode)

0 commit comments

Comments
 (0)