Comparing version 5.3.0 to 5.4.0
23
files.js
@@ -35,2 +35,4 @@ /*files.js*/ | ||
const copyFile = function (sourcePath, destination) { | ||
/* fs.copyFile exists in Node 9+ | ||
todo if dest cannot be reached created folders until it is*/ | ||
return new Promise(function (resolve, reject) { | ||
@@ -50,2 +52,20 @@ if (!fs.existsSync(sourcePath)) { | ||
const deleteFile = function (sourcePath) { | ||
return new Promise(function (resolve, reject) { | ||
fs.unlink(sourcePath, function(error) { | ||
if(error && error.code == "ENOENT") { | ||
// file doens't exist | ||
resolve(`File ${sourcePath} doesn't exist, won't remove it.`); | ||
} else if (error) { | ||
// other errors, e.g. maybe we don't have enough permission | ||
reject(`Error occurred while trying to remove file ${sourcePath}`); | ||
} else { | ||
resolve(`removed`); | ||
} | ||
}); | ||
}); | ||
}; | ||
module.exports = { | ||
@@ -55,3 +75,4 @@ textFileContentPromiseFromPath, | ||
concatenateFiles, | ||
copyFile | ||
copyFile, | ||
deleteFile | ||
}; |
{ | ||
"name": "utilsac", | ||
"version": "5.3.0", | ||
"version": "5.4.0", | ||
"description": "tools mostly", | ||
@@ -5,0 +5,0 @@ "main": "files.js", |
@@ -13,3 +13,4 @@ # Utilities and random js files | ||
concatenateFiles, | ||
copyFile | ||
copyFile, | ||
deleteFile | ||
} from "./files.js" | ||
@@ -16,0 +17,0 @@ ``` |
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
17111
267
60