12345678910111213141516171819 |
- const fs = require('fs');
- const Path = require('path');
- const deleteFolderRecursive = function(path) {
- if (fs.existsSync(path)) {
- fs.readdirSync(path).forEach((file, index) => {
- const curPath = Path.join(path, file);
- if (fs.lstatSync(curPath).isDirectory()) { // recurse
- deleteFolderRecursive(curPath);
- } else { // delete file
- fs.unlinkSync(curPath);
- }
- });
- fs.rmdirSync(path);
- }
- };
- module.exports = deleteFolderRecursive
|