Comparing version 1.0.20 to 1.0.21
12
index.js
@@ -8,3 +8,3 @@ const { join, parse } = require('path'); | ||
let dest = typeof _dest === 'string' ? _dest : undefined; | ||
const defOpts = { overwrite: true, copy: false }; | ||
const defOpts = { overwrite: true, copy: false, log: true }; | ||
const opts = isObj(_opts) ? Object.assign(defOpts, _opts) : defOpts; | ||
@@ -15,3 +15,3 @@ let msg; | ||
msg = 'Invalid argument(s).'; | ||
log(msg); | ||
if (opts.log) log(msg); | ||
return new CustomError(1, msg); | ||
@@ -23,3 +23,3 @@ } | ||
msg = ['No such file or directory: ', src]; | ||
log(...msg); | ||
if (opts.log) log(...msg); | ||
return new CustomError(2, ...msg); | ||
@@ -36,3 +36,3 @@ } | ||
msg = ['Destination already exists: ', dest]; | ||
log(...msg); | ||
if (opts.log) log(...msg); | ||
return new CustomError(3, ...msg); | ||
@@ -57,3 +57,3 @@ } | ||
msg = ['Destination already exists: ', dest]; | ||
log(...msg); | ||
if (opts.log) log(...msg); | ||
return new CustomError(3, ...msg); | ||
@@ -71,3 +71,3 @@ } | ||
msg = ['Destination is an existing file: ', dest]; | ||
log(...msg); | ||
if (opts.log) log(...msg); | ||
return new CustomError(4, ...msg); | ||
@@ -74,0 +74,0 @@ } else { |
{ | ||
"name": "mvdir", | ||
"version": "1.0.20", | ||
"version": "1.0.21", | ||
"description": "Move or copy files and directories. (async, recursive, across devices, copy & delete fallback, minimalistic with 0 dependencies)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
[](https://nodei.co/npm/mvdir/) | ||
[](https://nodei.co/npm/mvdir/) | ||
[](https://travis-ci.com/m-ahmadi/mvdir) | ||
@@ -39,2 +39,7 @@ [](https://packagephobia.now.sh/result?p=mvdir@latest) | ||
await mvdir('dir1', 'dir2', { overwrite: false }); // error if dir2 already exists. | ||
``` | ||
``` | ||
### Don't log errors: | ||
```javascript | ||
await mvdir('dir1', 'dir2', { log: false }); | ||
``` |
10472
45