summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authordustinnewman98 <dustinnewman98@gmail.com>2018-02-17 16:09:05 -0800
committerMatheus Marchini <matheus@sthima.com>2018-02-20 10:06:29 -0300
commite83adf87f58c7144e745ed18a79202577739b97c (patch)
tree624b075d176eabc4860737e631ba97d238d8a569 /doc
parent2caa1f54582902a4feae9a4c7a2e30c6718f7005 (diff)
downloadandroid-node-v8-e83adf87f58c7144e745ed18a79202577739b97c.tar.gz
android-node-v8-e83adf87f58c7144e745ed18a79202577739b97c.tar.bz2
android-node-v8-e83adf87f58c7144e745ed18a79202577739b97c.zip
doc: improved documentation for fs.unlink()
Refs: https://github.com/nodejs/node/issues/11135 PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/fs.md18
1 files changed, 16 insertions, 2 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md
index a4a9e5fd3f..ae559d0ecf 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -2749,8 +2749,21 @@ changes:
* `callback` {Function}
* `err` {Error}
-Asynchronous unlink(2). No arguments other than a possible exception are given
-to the completion callback.
+Asynchronously removes a file or symbolic link. No arguments other than a
+possible exception are given to the completion callback.
+
+```js
+// Assuming that 'path/file.txt' is a regular file.
+fs.unlink('path/file.txt', (err) => {
+ if (err) throw err;
+ console.log('path/file.txt was deleted');
+});
+```
+
+`fs.unlink()` will not work on a directory, empty or otherwise. To remove a
+directory, use [`fs.rmdir()`][].
+
+See also: unlink(2)
## fs.unlinkSync(path)
<!-- YAML
@@ -4472,6 +4485,7 @@ The following constants are meant for use with the [`fs.Stats`][] object's
[`fs.read()`]: #fs_fs_read_fd_buffer_offset_length_position_callback
[`fs.readFile()`]: #fs_fs_readfile_path_options_callback
[`fs.readFileSync()`]: #fs_fs_readfilesync_path_options
+[`fs.rmdir()`]: #fs_fs_rmdir_path_callback
[`fs.stat()`]: #fs_fs_stat_path_callback
[`fs.utimes()`]: #fs_fs_utimes_path_atime_mtime_callback
[`fs.watch()`]: #fs_fs_watch_filename_options_listener