function rmdirRecursive(dir, clbk){
    dir = resolve(dir).fullPath;
    
    if(clbk === null || typeof clbk === 'undefined') clbk = function(err) {};
    fs.readdir(dir, function(err, files) {
        if(err) return clbk(err);
        if(!files) return clbk(new Error('fsExt.rmdirRecursive: removing folders failed, folder not exists'));
        
        (function rmFile(err){
            if(err) return clbk(err);
            var filename = files.shift();
            if(filename === null || typeof filename === 'undefined') return fs.rmdir(dir, clbk);
            var file = dir+'/'+filename;
            
            fs.lstat(file, function(err, stat){
                if(err) return clbk(err);
                if(stat.isDirectory()) rmdirRecursive(file, rmFile);
                else fs.unlink(file, rmFile);
            });
        })();
    });
}
function rmdirRecursive(dir, clbk){
    dir = resolve(dir).fullPath;
    
    if(clbk === null || typeof clbk === 'undefined') clbk = function(err) {};
    fs.readdir(dir, function(err, files) {
        if(err) return clbk(err);
        if(!files) return clbk(new Error('fsExt.rmdirRecursive: removing folders failed, folder not exists'));
        
        (function rmFile(err){
            if(err) return clbk(err);
            var filename = files.shift();
            if(filename === null || typeof filename === 'undefined') return fs.rmdir(dir, clbk);
            var file = dir+'/'+filename;
            
            fs.lstat(file, function(err, stat){
                if(err) return clbk(err);
                if(stat.isDirectory()) rmdirRecursive(file, rmFile);
                else fs.unlink(file, rmFile);
            });
        })();
    });
}
function rmdirRecursive ( dir , clbk ) { dir = resolve ( dir ) . fullPath ; if ( clbk === null || typeof clbk === 'undefined' ) clbk = function ( err ) { } ; fs . readdir ( dir , function ( err , files ) { if ( err ) return clbk ( err ) ; if ( ! files ) return clbk ( new Error ( 'fsExt.rmdirRecursive: removing folders failed, folder not exists' ) ) ; ( function rmFile ( err ) { if ( err ) return clbk ( err ) ; var filename = files . shift ( ) ; if ( filename === null || typeof filename === 'undefined' ) return fs . rmdir ( dir , clbk ) ; var file = dir + '/' + filename ; fs . lstat ( file , function ( err , stat ) { if ( err ) return clbk ( err ) ; if ( stat . isDirectory ( ) ) rmdirRecursive ( file , rmFile ) ; else fs . unlink ( file , rmFile ) ; } ) ; } ) ( ) ; } ) ; }
/*
borrowed from: https://github.com/ryanmcgrath/wrench-js/blob/master/lib/wrench.js
wrench.rmdirRecursive("directory_path", callback);

Recursively dives through directories and obliterates everything about it.
/ * borrowed from : https : // github . com / ryanmcgrath / wrench - js / blob / master / lib / wrench . js wrench . rmdirRecursive ( directory_path callback ) ;