Comparing version 0.0.5 to 0.0.6
46
index.js
@@ -5,44 +5,22 @@ var fs = require('fs'); | ||
var mkdir = function (dist, callback) { | ||
var list = []; | ||
dist = path.resolve(dist); | ||
dist.split(/[\\\/]/) | ||
.reduce(function (first, second) { | ||
var _path = path.join(first, second); | ||
list.push(_path); | ||
return _path; | ||
}); | ||
(function () { | ||
var args = arguments, | ||
_path = ''; | ||
if (list.length > 0) { | ||
_path = list.shift(); | ||
fs.exists(_path, function (exists) { | ||
if (exists) { | ||
args.callee(); | ||
} else { | ||
fs.mkdir(_path, function (err) { | ||
if (err) { | ||
callback && callback(err); | ||
} else { | ||
args.callee(); | ||
} | ||
}) | ||
} | ||
fs.exists(dist, function (exists) { | ||
if (!exists) { | ||
mkdir(path.dirname(dist), function () { | ||
fs.mkdir(dist, function (err) { | ||
callback && callback(err); | ||
}); | ||
}); | ||
} else { | ||
callback && callback(null, _path); | ||
callback && callback(null); | ||
} | ||
})(); | ||
}); | ||
}; | ||
mkdir.sync = function (dist) { | ||
dist = path.resolve(dist); | ||
dist.split(/[\\\/]/) | ||
.reduce(function (first, second) { | ||
var _path = path.join(first || '/', second); | ||
if (!fs.existsSync(_path)) { | ||
fs.mkdirSync(_path); | ||
} | ||
return _path; | ||
}); | ||
if (!fs.existsSync(dist)) { | ||
mkdir.sync(path.dirname(dist)); | ||
fs.mkdirSync(dist); | ||
} | ||
}; | ||
module.exports = mkdir; |
@@ -21,3 +21,3 @@ { | ||
}, | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"readmeFilename": "README.md", | ||
@@ -24,0 +24,0 @@ "bugs": { |
Possible typosquat attack
Supply chain riskThere is a package with a similar name that is downloaded much more often.
Did you mean |
---|
mkdirp |
0
1602
23