foalts2-cli
Version:
CLI tool for FoalTS
24 lines (23 loc) • 706 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.rmDirAndFilesIfExist = void 0;
// std
const fs_1 = require("fs");
const path_1 = require("path");
function rmDirAndFilesIfExist(path) {
if (!fs_1.existsSync(path)) {
return;
}
const files = fs_1.readdirSync(path);
for (const file of files) {
const stats = fs_1.statSync(path_1.join(path, file));
if (stats.isDirectory()) {
rmDirAndFilesIfExist(path_1.join(path, file));
}
else {
fs_1.unlinkSync(path_1.join(path, file));
}
}
fs_1.rmdirSync(path);
}
exports.rmDirAndFilesIfExist = rmDirAndFilesIfExist;