chore: port clean script to node v10
This commit is contained in:
parent
d6b7e9eb95
commit
b631f654e1
1 changed files with 18 additions and 1 deletions
|
|
@ -9,4 +9,21 @@ import * as path from "path";
|
|||
const ROOT_DIR = path.resolve(__dirname, "..");
|
||||
const DIST_DIR = path.join(ROOT_DIR, "dist");
|
||||
|
||||
fs.rmdirSync(DIST_DIR, { recursive: true });
|
||||
const rmdirRecursive = (dirPath: string): void => {
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
return;
|
||||
}
|
||||
const entryNames = fs.readdirSync(dirPath);
|
||||
for (const entryName of entryNames) {
|
||||
const entryPath = path.join(dirPath, entryName);
|
||||
const dirent = fs.lstatSync(entryPath);
|
||||
if (dirent.isDirectory()) {
|
||||
rmdirRecursive(entryPath);
|
||||
} else {
|
||||
fs.unlinkSync(entryPath);
|
||||
}
|
||||
}
|
||||
fs.rmdirSync(dirPath);
|
||||
};
|
||||
|
||||
rmdirRecursive(DIST_DIR);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue