Skip to content

Instantly share code, notes, and snippets.

@manan-jadhav
manan-jadhav / node-rm-rf.js
Created May 7, 2016 04:05 — forked from geedew/node-rm-rf.js
Removing a directory that is not empty in NodeJS
var fs = require('fs');
var deleteFolderRecursive = function(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);
}