Skip to content

Instantly share code, notes, and snippets.

@adohe-zz
Created February 12, 2014 05:56
Show Gist options
  • Save adohe-zz/8950691 to your computer and use it in GitHub Desktop.
Save adohe-zz/8950691 to your computer and use it in GitHub Desktop.
mkdir recursion in node
var path = require('path');
var fs = require('fs');
var mkdirs = function(dir, mode, callback) {
fs.exists(dir, function(exists) {
if(exists) {
callback(dir);
} else {
mkdirs(path.dirname(dir), mode, function() {
fs.mkdir(dir, mode, callback);
});
}
});
};
mkdirs('/abc/def', 000, function(dir){})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment