-
-
Save ingoradatz/70babc142a8a75c7cdcb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"); | |
var path = require("path"); | |
var rmdir = function(dir) { | |
var list = fs.readdirSync(dir); | |
for(var i = 0; i < list.length; i++) { | |
var filename = path.join(dir, list[i]); | |
var stat = fs.statSync(filename); | |
if(filename == "." || filename == "..") { | |
// pass these files | |
} else if(stat.isDirectory()) { | |
// rmdir recursively | |
rmdir(filename); | |
} else { | |
// rm fiilename | |
fs.unlinkSync(filename); | |
} | |
} | |
fs.rmdirSync(dir); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment