1 var fs = require('graceful-fs')
2 var path = require('path')
4 var o777 = parseInt('0777', 8)
6 function mkdirsSync (p, opts, made) {
7 if (!opts || typeof opts !== 'object') {
12 var xfs = opts.fs || fs
14 if (mode === undefined) {
15 mode = o777 & (~process.umask())
17 if (!made) made = null
22 xfs.mkdirSync(p, mode)
27 made = mkdirsSync(path.dirname(p), opts, made)
28 mkdirsSync(p, opts, made)
31 // In the case of any other error, just see if there's a dir
32 // there already. If so, then hooray! If not, then something
37 stat = xfs.statSync(p)
41 if (!stat.isDirectory()) throw err0
49 module.exports = mkdirsSync