rename-overwrite
Advanced tools
Comparing version 2.0.2 to 3.0.0
10
index.js
'use strict' | ||
const fs = require('graceful-fs') | ||
const path = require('path') | ||
const promisify = require('util').promisify | ||
@@ -8,2 +9,3 @@ const rimraf = promisify(require('rimraf')) | ||
const rename = promisify(fs.rename) | ||
const mkdir = promisify(fs.mkdir) | ||
@@ -26,2 +28,6 @@ module.exports = async function renameOverwrite (oldPath, newPath) { | ||
break | ||
case 'ENOENT': | ||
await mkdir(path.dirname(newPath), { recursive: true }) | ||
await rename(oldPath, newPath) | ||
break | ||
default: | ||
@@ -44,2 +50,6 @@ throw err | ||
return | ||
case 'ENOENT': | ||
fs.mkdirSync(path.dirname(newPath), { recursive: true }) | ||
renameOverwriteSync(oldPath, newPath) | ||
return | ||
default: | ||
@@ -46,0 +56,0 @@ throw err |
{ | ||
"name": "rename-overwrite", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"description": "Like `fs.rename` but overwrites existing file or directory", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=10.12" | ||
}, | ||
@@ -29,13 +30,13 @@ "scripts": { | ||
"dependencies": { | ||
"graceful-fs": "^4.1.11", | ||
"rimraf": "^3.0.0" | ||
"graceful-fs": "^4.2.3", | ||
"rimraf": "^3.0.2" | ||
}, | ||
"devDependencies": { | ||
"load-json-file": "6.1.0", | ||
"package-preview": "2.0.0", | ||
"standard": "13.1.0", | ||
"tape": "^4.7.0", | ||
"tempy": "^0.3.0", | ||
"write-json-file": "4.1.0" | ||
"load-json-file": "6.2.0", | ||
"package-preview": "3.0.0", | ||
"standard": "14.3.3", | ||
"tape": "^5.0.0", | ||
"tempy": "^0.5.0", | ||
"write-json-file": "4.2.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4536
6
58
Updatedgraceful-fs@^4.2.3
Updatedrimraf@^3.0.2