fs.rename but works with files across devices. same as the unix utility 'mv'

Usage no npm install needed!

<script type="module">
  import mvLite from '';



A lighter version of mv without the support for directory moving between devices (directory moving within same device works as well as files between devices).

This means this project has no dependancy to rimraf or ncp making it a lot lighter and smaller.


var mv = require('mv-lite');

mv('source/file', 'dest/file', function(err) {
  // done. it tried fs.rename first, and then falls back to
  // piping the source file to the dest file and then unlinking
  // the source file.

Another example:

mv('source/dir', 'dest/a/b/c/dir', {mkdirp: true}, function(err) {
  // done. it first created all the necessary directories, and then
  // tries fs.rename

Another example:

mv('source/file', 'dest/file', {clobber: false}, function(err) {
  // done. If 'dest/file' exists, an error is returned
  // with err.code === 'EEXIST'.