Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
function mkdirP (p, fn, made) {
if (!made) made = null;
var cb = fn || function () {};
p = path.resolve(p);
fs.mkdir(p, function (err) {
if (!err) return cb(null, made || p);
if (err.code != 'ENOENT') return err;
mkdirP(path.dirname(p), mode, function (err, made) {
if (err) cb(err, made);
return mkdirP(p, cb, made);
* usage
mkdirP('/Users/euforic/test_cases/mkdirP', function(){

This comment has been minimized.

Show comment Hide comment

euforic Nov 21, 2013


euforic commented Nov 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment