-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
doc: improved documentation for fs.unlink() #18843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b531ac0
2272df5
82b486c
8e2e47b
55f37ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2745,12 +2745,31 @@ changes: | |
| it will emit a deprecation warning. | ||
| --> | ||
|
|
||
| * `path` {string|Buffer|URL} | ||
| * `path` {string|Buffer|URL} File name or file descriptor | ||
| * `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'); | ||
| }); | ||
| ``` | ||
|
|
||
| Note that unlink() will not work on a directory, empty or otherwise. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also recommend dropping |
||
|
|
||
| ```js | ||
| // Assuming that 'tmpDir' is a directory. | ||
| fs.unlink('tmpDir', (err) => { | ||
| // err is not null because a directory cannot be deleted through unlink(). | ||
| }); | ||
| ``` | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually think we do not need an error example here. |
||
| See also: unlink(2) | ||
|
|
||
| ## fs.unlinkSync(path) | ||
| <!-- YAML | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this really be a file descriptor? Also, "file" is not accurate, is it? This could be a symlink
or a directory, couldn't it? I think "path" is probably the best description, so I don't know that this needs a text explanation.