Node.js examples for File:Directory
Sync recursive delete folder
var path = require('path'); var fs = require('fs'); var crypto = require('crypto'); /*sync recursive delete folder*/ exports.rmdirSync = function(p) { if(fs.existsSync(p)){ var stat = fs.statSync(p); if(stat.isDirectory()){ var files = fs.readdirSync(p); files.forEach(function(file) { var fullName = path.join(p, file); if (fs.statSync(fullName).isDirectory()) { exports.rmdirSync(fullName); } else {/*from ww w . ja v a 2 s . c om*/ fs.unlinkSync(fullName); } }); fs.rmdirSync(p); }else{ fs.unlinkSync(p); } } }