Skip to content

Instantly share code, notes, and snippets.

@laispace
Created January 5, 2015 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laispace/c783348f69becbbcec8e to your computer and use it in GitHub Desktop.
Save laispace/c783348f69becbbcec8e to your computer and use it in GitHub Desktop.
removeFolder.js
deleteFolderRecursive = function(path) {
var files = [];
if( fs.existsSync(path) ) {
files = fs.readdirSync(path);
files.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