forked from svrjs/svrjs
17 lines
No EOL
434 B
JavaScript
17 lines
No EOL
434 B
JavaScript
const fs = require("fs");
|
|
|
|
function deleteFolderRecursive(path) {
|
|
if (fs.existsSync(path)) {
|
|
fs.readdirSync(path).forEach(function (file) {
|
|
const curPath = path + "/" + file;
|
|
if (fs.statSync(curPath).isDirectory()) { // recurse
|
|
deleteFolderRecursive(curPath);
|
|
} else { // delete file
|
|
fs.unlinkSync(curPath);
|
|
}
|
|
});
|
|
fs.rmdirSync(path);
|
|
}
|
|
}
|
|
|
|
module.exports = deleteFolderRecursive; |