mirror of
https://github.com/xuxiaobo-bobo/boda_jsEnv.git
synced 2025-04-22 03:15:25 +08:00
20 lines
480 B
JavaScript
20 lines
480 B
JavaScript
|
|
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
|