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 <[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]>
  • 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.