Skip to content

Instantly share code, notes, and snippets.

@ingoradatz
Forked from tkihira/gist:2367067
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ingoradatz/70babc142a8a75c7cdcb to your computer and use it in GitHub Desktop.
Save ingoradatz/70babc142a8a75c7cdcb to your computer and use it in GitHub Desktop.
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