diff options
author | punteek <prateek1@ucla.edu> | 2018-02-16 00:44:04 -0800 |
---|---|---|
committer | Matheus Marchini <matheus@sthima.com> | 2018-03-05 16:52:05 -0300 |
commit | 1d2ab79f2ce0057df1c0f0fe5eef15c143ad9942 (patch) | |
tree | f11892f7c92b10635e8bd1704dbdcf411080e6db /doc | |
parent | 1e8d110e640c658e4f6ed7540db62d063269ba6c (diff) | |
download | android-node-v8-1d2ab79f2ce0057df1c0f0fe5eef15c143ad9942.tar.gz android-node-v8-1d2ab79f2ce0057df1c0f0fe5eef15c143ad9942.tar.bz2 android-node-v8-1d2ab79f2ce0057df1c0f0fe5eef15c143ad9942.zip |
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/fs.md | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md index a864503dbd..d1eb765aad 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2623,8 +2623,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 |