
var fs = require("fs");
var del = require('del');

function delDir(path, isSelf) {
    let files = [];
    if (fs.existsSync(path)) {
        files = fs.readdirSync(path);
        files.forEach((file, index) => {
            let curPath = path + "/" + file;
            if (fs.statSync(curPath).isDirectory()) {
                delDir(curPath); //递归删除文件夹
            } else {
                fs.unlinkSync(curPath); //删除文件
            }
        });
        if (!isSelf) fs.rmdirSync(path);
    }
}
var paths = './released/';//设置删除路径
// delDir(paths, true);//删除文件夹
del(paths).then(() => {
    fs.mkdirSync(paths);
}).catch(()=>{
    fs.mkdirSync(paths);
})