website/node_modules/fs-extra/docs/move.md

move(src, dest, [options, callback])

Moves a file or directory, even across devices.

Example:

const fs = require('fs-extra')

fs.move('/tmp/somefile', '/tmp/does/not/exist/yet/somefile', err => {
  if (err) return console.error(err)

  console.log('success!')
})

fs.move('/tmp/somefile', '/tmp/does/not/exist/yet/somefile')
.then(() => {
  console.log('success!')
})
.catch(err => {
  console.error(err)
})

Using overwrite option

const fs = require('fs-extra')

fs.move('/tmp/somedir', '/tmp/may/already/existed/somedir', { overwrite: true }, err => {
  if (err) return console.error(err)

  console.log('success!')
})


JohnCoene/chirp documentation built on May 25, 2021, 6:33 p.m.