utils-cui-del
v1.0.0
Published
```javascript function copydir(dir, newdir) { !fs.existsSync(newdir) && fs.mkdirSync(newdir); fs.readFileSync(dir).forEach(item => { let dirname = dir + '/' + item; let newdirName = newdir + '/' + item; if (fs.statSyn
Downloads
4
Readme
#fs算法
##fs复制文件夹
function copydir(dir, newdir) {
!fs.existsSync(newdir) && fs.mkdirSync(newdir);
fs.readFileSync(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.readFileSync(fileSrc).forEach(item => {
item = fileSrc + '/' + item;
if (fs.statSync(item).isFile()) {
fs.unlinkSync(item);
} else {
del(item);
}
})
fs.rmdirSync(fileSrc);
}