Skip to content

Commit

Permalink
doc: add simple example to rename function
Browse files Browse the repository at this point in the history
Added a simple example showing how to rename
a file.

Refs: https://github.com/nodejs/node/issues11135

Backport-PR-URL: #22380
PR-URL: #18812
Reviewed-By: Matheus Marchini <matheus@sthima.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
punteek authored and MylesBorins committed Sep 6, 2018
1 parent d9895c4 commit e2190ad
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2238,8 +2238,19 @@ changes:
* `callback` {Function}
* `err` {Error}

Asynchronous rename(2). No arguments other than a possible exception are given
to the completion callback.
Asynchronously rename file at `oldPath` to the pathname provided
as `newPath`. In the case that `newPath` already exists, it will
be overwritten. No arguments other than a possible exception are
given to the completion callback.

See also: rename(2).

```js
fs.rename('oldFile.txt', 'newFile.txt', (err) => {
if (err) throw err;
console.log('Rename complete!');
});
```

## fs.renameSync(oldPath, newPath)
<!-- YAML
Expand Down

0 comments on commit e2190ad

Please sign in to comment.