clovie
Version:
Vintage web dev tooling with modern quality of life
21 lines (19 loc) • 442 B
JavaScript
import fs from 'fs';
export default function rmDir (dirPath) {
try {
var files = fs.readdirSync(dirPath)
}
catch(e) {
return;
}
if (files.length > 0)
for (var i = 0; i < files.length; i++) {
var filePath = dirPath + '/' + files[i];
if (fs.statSync(filePath).isFile())
fs.unlinkSync(filePath);
else
rmDir(filePath);
}
fs.rmdirSync(dirPath);
console.log(dirPath + ' cleaned')
};