Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View mkdirp.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 
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(){
console.log(fs.existsSync('/Users/euforic/test_cases/mkdirP'));
});
Owner

@candrade ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.