import fs from 'fs' import path from 'path' export default function deleteFile(url, excludes = []) { let files = [] if (fs.existsSync(url)) { files = fs.readdirSync(url) files.forEach(function (file, index) { if (excludes.indexOf(file) === -1) { const curPath = path.join(url, file) if (fs.statSync(curPath).isDirectory()) { deleteFile(curPath) } else { if (curPath.endsWith('.html.html')) { fs.unlinkSync(curPath) console.log('已删除文件:', file) } } } }) } else { console.log('给定的路径不存在!') } }