Skip to content

Commit a1902ca

Browse files
dustinnewmanMylesBorins
authored andcommitted
doc: improved documentation for fs.unlink()
Refs: #11135 PR-URL: #18843 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Matheus Marchini <[email protected]>
1 parent 8c5ad68 commit a1902ca

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

doc/api/fs.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -2444,8 +2444,21 @@ changes:
24442444
* `callback` {Function}
24452445
* `err` {Error}
24462446

2447-
Asynchronous unlink(2). No arguments other than a possible exception are given
2448-
to the completion callback.
2447+
Asynchronously removes a file or symbolic link. No arguments other than a
2448+
possible exception are given to the completion callback.
2449+
2450+
```js
2451+
// Assuming that 'path/file.txt' is a regular file.
2452+
fs.unlink('path/file.txt', (err) => {
2453+
if (err) throw err;
2454+
console.log('path/file.txt was deleted');
2455+
});
2456+
```
2457+
2458+
`fs.unlink()` will not work on a directory, empty or otherwise. To remove a
2459+
directory, use [`fs.rmdir()`][].
2460+
2461+
See also: unlink(2)
24492462

24502463
## fs.unlinkSync(path)
24512464
<!-- YAML
@@ -3173,6 +3186,7 @@ The following constants are meant for use with the [`fs.Stats`][] object's
31733186
[`fs.read()`]: #fs_fs_read_fd_buffer_offset_length_position_callback
31743187
[`fs.readFile()`]: #fs_fs_readfile_path_options_callback
31753188
[`fs.readFileSync()`]: #fs_fs_readfilesync_path_options
3189+
[`fs.rmdir()`]: #fs_fs_rmdir_path_callback
31763190
[`fs.stat()`]: #fs_fs_stat_path_callback
31773191
[`fs.utimes()`]: #fs_fs_utimes_path_atime_mtime_callback
31783192
[`fs.watch()`]: #fs_fs_watch_filename_options_listener

0 commit comments

Comments
 (0)