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

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 Mar 6, 2018
1 parent 5583547 commit d411d1d
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 @@ -2529,8 +2529,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 d411d1d

Please sign in to comment.