chore: port clean script to node v10

This commit is contained in:
M. George Hansen 2020-06-02 00:00:43 -07:00
parent d6b7e9eb95
commit b631f654e1
Signed by: mgeorgehansen
SSH key fingerprint: SHA256:JlIGiQLPyQ2RHTH3a2oVlb20Xkh9Glr8DUF4YTXHJxM

View file

@ -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);