UNPKG

@foal/cli

Version:

CLI tool for FoalTS

23 lines (22 loc) 684 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.rmDirAndFilesIfExist = rmDirAndFilesIfExist; // std const fs_1 = require("fs"); const path_1 = require("path"); function rmDirAndFilesIfExist(path) { if (!(0, fs_1.existsSync)(path)) { return; } const files = (0, fs_1.readdirSync)(path); for (const file of files) { const stats = (0, fs_1.statSync)((0, path_1.join)(path, file)); if (stats.isDirectory()) { rmDirAndFilesIfExist((0, path_1.join)(path, file)); } else { (0, fs_1.unlinkSync)((0, path_1.join)(path, file)); } } (0, fs_1.rmdirSync)(path); }