提交 48e3a670 编写于 作者: fxy060608's avatar fxy060608

fix: use fs-extra empty dir (#3650)

上级 ed9bde93
import fs from 'fs' import { emptyDirSync } from 'fs-extra'
import path from 'path' export function emptyDir(dir: string): void {
export function emptyDir(dir: string, skip?: string[]): void { return emptyDirSync(dir)
for (const file of fs.readdirSync(dir)) {
if (skip?.includes(file)) {
continue
}
const abs = path.resolve(dir, file)
// baseline is Node 12 so can't use rmSync :(
if (fs.lstatSync(abs).isDirectory()) {
emptyDir(abs)
fs.rmdirSync(abs)
} else {
fs.unlinkSync(abs)
}
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册