15 lines
386 B
JavaScript
15 lines
386 B
JavaScript
const fs = require('fs')
|
|
|
|
module.exports = function deleteFolderRecursive(path) {
|
|
if (fs.existsSync(path)) {
|
|
fs.readdirSync(path).forEach(function(file, index){
|
|
var curPath = path + "/" + file;
|
|
if (fs.lstatSync(curPath).isDirectory()) { // recurse
|
|
deleteFolderRecursive(curPath);
|
|
} else { // delete file
|
|
fs.unlinkSync(curPath);
|
|
}
|
|
});
|
|
fs.rmdirSync(path);
|
|
}
|
|
}; |