1rmDir = function(dirPath, removeSelf) {
2 try { var files = fs.readdirSync(dirPath); }
3 catch(e) { return; }
4 if (files.length > 0)
5 for (var i = 0; i < files.length; i++) {
6 var filePath = dirPath + '/' + files[i];
7 if (fs.statSync(filePath).isFile())
8 fs.unlinkSync(filePath);
9 else
10 rmDir(filePath);
11 }
12 if (removeSelf)
13 fs.rmdirSync(dirPath);
14};