Вход Регистрация
Файл: error-kitty/node_modules/mocha/node_modules/jade/node_modules/mkdirp/index.js
Строк: 40
<?php
var path = require('path');
var 
fs = require('fs');

module.exports mkdirP.mkdirp mkdirP.mkdirP mkdirP;

function 
mkdirP (pmodef) {
    if (
typeof mode === 'function' || mode === undefined) {
        
mode;
        
mode 0777 & (~process.umask());
    }
    
    var 
cb || function () {};
    if (
typeof mode === 'string'mode parseInt(mode8);
    
path.resolve(p);

    
fs.mkdir(pmode, function (er) {
        if (!
er) return cb();
        switch (
er.code) {
            case 
'ENOENT':
                
mkdirP(path.dirname(p), mode, function (er) {
                    if (
ercb(er);
                    else 
mkdirP(pmodecb);
                });
                break;

            case 
'EEXIST':
                
fs.stat(p, function (er2stat) {
                    
// if the stat fails, then that's super weird.
                    // let the original EEXIST be the failure reason.
                    
if (er2 || !stat.isDirectory()) cb(er)
                    else 
cb();
                });
                break;

            default:
                
cb(er);
                break;
        }
    });
}

mkdirP.sync = function sync (pmode) {
    if (
mode === undefined) {
        
mode 0777 & (~process.umask());
    }
    
    if (
typeof mode === 'string'mode parseInt(mode8);
    
path.resolve(p);
    
    try {
        
fs.mkdirSync(pmode)
    }
    catch (
err0) {
        switch (
err0.code) {
            case 
'ENOENT' :
                var 
err1 sync(path.dirname(p), mode)
                if (
err1) throw err1;
                else return 
sync(pmode);
                break;
            
            case 
'EEXIST' :
                var 
stat;
                try {
                    
stat fs.statSync(p);
                }
                catch (
err1) {
                    throw 
err0
                
}
                if (!
stat.isDirectory()) throw err0;
                else return 
null;
                break;
            default :
                throw 
err0
                
break;
        }
    }
    
    return 
null;
};
?>
Онлайн: 1
Реклама