Skip to content

Commit 0e4f426

Browse files
punteekMylesBorins
authored andcommitted
doc: add simple example to rename function
Added a simple example showing how to rename a file. Refs: https://github.com/nodejs/node/issues11135 PR-URL: #18812 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 95f6467 commit 0e4f426

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

doc/api/fs.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -2529,8 +2529,19 @@ changes:
25292529
* `callback` {Function}
25302530
* `err` {Error}
25312531

2532-
Asynchronous rename(2). No arguments other than a possible exception are given
2533-
to the completion callback.
2532+
Asynchronously rename file at `oldPath` to the pathname provided
2533+
as `newPath`. In the case that `newPath` already exists, it will
2534+
be overwritten. No arguments other than a possible exception are
2535+
given to the completion callback.
2536+
2537+
See also: rename(2).
2538+
2539+
```js
2540+
fs.rename('oldFile.txt', 'newFile.txt', (err) => {
2541+
if (err) throw err;
2542+
console.log('Rename complete!');
2543+
});
2544+
```
25342545

25352546
## fs.renameSync(oldPath, newPath)
25362547
<!-- YAML

0 commit comments

Comments
 (0)