@foal/cli
Version:
CLI tool for FoalTS
30 lines (29 loc) • 820 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RmdirCommandService = void 0;
// std
const promises_1 = require("node:fs/promises");
/**
* Service for removing directories and all their contents.
*/
class RmdirCommandService {
/**
* Remove a directory and all its contents, including any subdirectories and files.
*
* @param {string} path - The path of the directory
* @returns {Promise<void>}
*/
async run(path) {
try {
await (0, promises_1.readdir)(path);
}
catch (error) {
if (error.code === 'ENOENT') {
return;
}
throw error;
}
await (0, promises_1.rm)(path, { recursive: true });
}
}
exports.RmdirCommandService = RmdirCommandService;