UNPKG

viewbot_x

Version:

基于react的前端页面性能监控插件 It's small board which can monitor click events or hashchange from page

26 lines (25 loc) 648 B
var fs = require('fs'); function cleanDist(dirPath){ let dirArr = [] // 检查文件是否存在 if (fs.existsSync(dirPath)){ // 读取文件夹 dirArr = fs.readdirSync(dirPath) dirArr.forEach(name => { let newPath = dirPath + '/' + name // 判断子目录 if(fs.statSync(newPath).isDirectory()){ // 是文件夹则递归删除 cleanDist(newPath) }else { // 否则直接删除文件 fs.unlinkSync(newPath) } }) // 最终删除空文件夹 fs.rmdirSync(dirPath) } } module.exports = { cleanDist }