fssuanfa-demo
v2.0.0
Published
```javascript const fs=require('fs');
Downloads
7
Readme
删除非空文件夹
const fs=require('fs');
//删除非空文件夹
const DelDir=(path)=>{
//读取子文件
const arr=fs.readdirSync(path);
//遍历子文件
arr.forEach((item)=>{
//拼接路径
item=path+'/'+item;
//获取文件信息
const info=fs.statSync(item);
//判断是不是文件
if(info.isFile()){
//删除文件
fs.unlinkSync(item);
}else{
//是文件夹
DelDir(item);
}
})
//删除文件夹
fs.rmdirSync(path);
}
DelDir('node_modules');