-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
doc: improved documentation for fs.unlink() #18843
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b531ac0
doc: improved documentation for fs.unlink()
dustinnewman 2272df5
fixup! address review comments
dustinnewman 82b486c
fixup! Added function to remove directory.
dustinnewman 8e2e47b
fixup! Addressed concerns.
dustinnewman 55f37ae
fixup! wrapped at 80 characters
dustinnewman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2749,8 +2749,20 @@ 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()`][]. | ||
|
||
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 | ||
|
@@ -4472,6 +4484,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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Oh, please wrap the line at 80 characters.