Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9c53060

Browse filesBrowse files
dustinnewmanMylesBorins
authored andcommitted
doc: improved documentation for fs.unlink()
Refs: #11135 PR-URL: #18843 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com>
1 parent 183c18c commit 9c53060
Copy full SHA for 9c53060

File tree

Expand file treeCollapse file tree

1 file changed

+16
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-2
lines changed
Open diff view settings
Collapse file

‎doc/api/fs.md‎

Copy file name to clipboardExpand all lines: doc/api/fs.md
+16-2Lines changed: 16 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2736,8 +2736,21 @@ changes:
27362736
* `callback` {Function}
27372737
* `err` {Error}
27382738

2739-
Asynchronous unlink(2). No arguments other than a possible exception are given
2740-
to the completion callback.
2739+
Asynchronously removes a file or symbolic link. No arguments other than a
2740+
possible exception are given to the completion callback.
2741+
2742+
```js
2743+
// Assuming that 'path/file.txt' is a regular file.
2744+
fs.unlink('path/file.txt', (err) => {
2745+
if (err) throw err;
2746+
console.log('path/file.txt was deleted');
2747+
});
2748+
```
2749+
2750+
`fs.unlink()` will not work on a directory, empty or otherwise. To remove a
2751+
directory, use [`fs.rmdir()`][].
2752+
2753+
See also: unlink(2)
27412754

27422755
## fs.unlinkSync(path)
27432756
<!-- YAML
@@ -3466,6 +3479,7 @@ The following constants are meant for use with the [`fs.Stats`][] object's
34663479
[`fs.read()`]: #fs_fs_read_fd_buffer_offset_length_position_callback
34673480
[`fs.readFile()`]: #fs_fs_readfile_path_options_callback
34683481
[`fs.readFileSync()`]: #fs_fs_readfilesync_path_options
3482+
[`fs.rmdir()`]: #fs_fs_rmdir_path_callback
34693483
[`fs.stat()`]: #fs_fs_stat_path_callback
34703484
[`fs.utimes()`]: #fs_fs_utimes_path_atime_mtime_callback
34713485
[`fs.watch()`]: #fs_fs_watch_filename_options_listener

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.