Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
27
Task/Make-directory-path/JavaScript/make-directory-path.js
Normal file
27
Task/Make-directory-path/JavaScript/make-directory-path.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
function mkdirp (p, cb) {
|
||||
cb = cb || function () {};
|
||||
p = path.resolve(p);
|
||||
|
||||
fs.mkdir(p, function (er) {
|
||||
if (!er) {
|
||||
return cb(null);
|
||||
}
|
||||
switch (er.code) {
|
||||
case 'ENOENT':
|
||||
// The directory doesn't exist. Make its parent and try again.
|
||||
mkdirp(path.dirname(p), function (er) {
|
||||
if (er) cb(er);
|
||||
else mkdirp(p, cb);
|
||||
});
|
||||
break;
|
||||
|
||||
// In the case of any other error, something is borked.
|
||||
default:
|
||||
cb(er);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue