How to use the renameSync function from graceful-fs

Find comprehensive JavaScript graceful-fs.renameSync code examples handpicked from public code repositorys.

511
512
513
514
515
516
517
518
519
520
521
522
exports.realpath = Promise.promisify(fs.realpath);
exports.realpathSync = fs.realpathSync;


// rename
exports.rename = Promise.promisify(fs.rename);
exports.renameSync = fs.renameSync;


// rmdir
exports.rmdir = rmdir;
exports.rmdirSync = rmdirSync;
fork icon9
star icon48
watch icon0

+ 7 other calls in file

21
22
23
24
25
26
27
28
29
30
tryRenameSync()

function tryRenameSync () {
  if (overwrite) {
    try {
      return fs.renameSync(src, dest)
    } catch (err) {
      if (err.code === 'ENOTEMPTY' || err.code === 'EEXIST' || err.code === 'EPERM') {
        removeSync(dest)
        options.overwrite = false // just overwriteed it, no need to do it again
fork icon0
star icon1
watch icon0

218
219
220
221
222
223
224
225
226
227
    fs.fsyncSync(fd)
  }
  fs.closeSync(fd)
  if (options.chown) fs.chownSync(tmpfile, options.chown.uid, options.chown.gid)
  if (options.mode) fs.chmodSync(tmpfile, options.mode)
  fs.renameSync(tmpfile, filename)
  removeOnExitHandler()
} catch (err) {
  if (fd) {
    try {
fork icon0
star icon0
watch icon0

+ 3 other calls in file