websnacks/scripts/clean.ts
M. George Hansen 5118a8174b
chore: replace eslint & prettier w/ biomejs (#21)
* chore: replace eslint & prettier w/ biomejs

* fix syntax error in ci.yml workflow

* ensure that build CI jobs only run if check job succeeds to save resources
2024-07-15 08:36:52 -07:00

31 lines
878 B
TypeScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import * as fs from "node:fs";
import * as path from "node:path";
const ROOT_DIR = path.resolve(__dirname, "..");
const DIST_DIR = path.join(ROOT_DIR, "dist");
const TEST_DIR = path.join(ROOT_DIR, ".temp");
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);
rmdirRecursive(TEST_DIR);