Created
October 25, 2016 07:01
-
-
Save jimmy-collazos/fa1f10c172694e6c4491ee24a0b45677 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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