Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2745,12 +2745,31 @@ changes:
it will emit a deprecation warning.
-->

* `path` {string|Buffer|URL}
* `path` {string|Buffer|URL} File name or file descriptor
Copy link
Copy Markdown
Member

@Trott Trott Feb 18, 2018

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.

* `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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unlink() needs backticks around it. Also, probably should be fs.unlink() for maximum clarity?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also recommend dropping Note that from the start of the sentence. Just tell me what I need to know, and that I need to note it. :-D


```js
// Assuming that 'tmpDir' is a directory.
fs.unlink('tmpDir', (err) => {
// err is not null because a directory cannot be deleted through unlink().
});
```

Copy link
Copy Markdown
Member

@BridgeAR BridgeAR Feb 18, 2018

Choose a reason for hiding this comment

The 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
Expand Down