Skip to content

Instantly share code, notes, and snippets.

@jimmy-collazos
Created October 25, 2016 07:01
Show Gist options
  • Save jimmy-collazos/fa1f10c172694e6c4491ee24a0b45677 to your computer and use it in GitHub Desktop.
Save jimmy-collazos/fa1f10c172694e6c4491ee24a0b45677 to your computer and use it in GitHub Desktop.
function deleteFolderRecursive(path) {
if(fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file, index) {
var curPath = path + '/' + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment