Skip to content

Commit e83adf8

Browse files
dustinnewmanMatheus Marchini
authored and
Matheus Marchini
committed
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 2caa1f5 commit e83adf8

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
@@ -2749,8 +2749,21 @@ changes:
27492749
* `callback` {Function}
27502750
* `err` {Error}
27512751

2752-
Asynchronous unlink(2). No arguments other than a possible exception are given
2753-
to the completion callback.
2752+
Asynchronously removes a file or symbolic link. No arguments other than a
2753+
possible exception are given to the completion callback.
2754+
2755+
```js
2756+
// Assuming that 'path/file.txt' is a regular file.
2757+
fs.unlink('path/file.txt', (err) => {
2758+
if (err) throw err;
2759+
console.log('path/file.txt was deleted');
2760+
});
2761+
```
2762+
2763+
`fs.unlink()` will not work on a directory, empty or otherwise. To remove a
2764+
directory, use [`fs.rmdir()`][].
2765+
2766+
See also: unlink(2)
27542767

27552768
## fs.unlinkSync(path)
27562769
<!-- YAML
@@ -4472,6 +4485,7 @@ The following constants are meant for use with the [`fs.Stats`][] object's
44724485
[`fs.read()`]: #fs_fs_read_fd_buffer_offset_length_position_callback
44734486
[`fs.readFile()`]: #fs_fs_readfile_path_options_callback
44744487
[`fs.readFileSync()`]: #fs_fs_readfilesync_path_options
4488+
[`fs.rmdir()`]: #fs_fs_rmdir_path_callback
44754489
[`fs.stat()`]: #fs_fs_stat_path_callback
44764490
[`fs.utimes()`]: #fs_fs_utimes_path_atime_mtime_callback
44774491
[`fs.watch()`]: #fs_fs_watch_filename_options_listener

0 commit comments

Comments
 (0)