untio-hua-delplus
v1.0.0
Published
```javascript function copydir(dir, newdir) { !fs.existsSync(newdir) && fs.mkdirSync(newdir); fs.readdirSync(dir).forEach(item => { let dirname = dir + '/' + item; let newdirName = newdir + '/' + item; if (fs.statSync
Downloads
1
Readme
#fs算法
##fs文件夹拷贝
function copydir(dir, newdir) {
!fs.existsSync(newdir) && fs.mkdirSync(newdir);
fs.readdirSync(dir).forEach(item => {
let dirname = dir + '/' + item;
let newdirName = newdir + '/' + item;
if (fs.statSync(dirname).isFile()) {
fs.copyFileSync(dirname, newdirName);
} else {
copydir(dirname, newdirName);
}
})
}
##fs文件删除代码
function del(fileSrc) {
fs.readdirSync(fileSrc).forEach(item => {
item = fileSrc + '/' + item;
console.log(item);
if (fs.statSync(item).isFile()) {
fs.unlinkSync(item);
} else {
del(item);
}
})
fs.rmdirSync(fileSrc);
}