lib/makedir.js
function makeme (dir,mode,cb){

    var callback = function(err,parent){
        //console.log('makeme: ',dir)
        if(err) throw new Error(err)
        if(parent){
            // replace root of dir with parent
            dir = path.join(parent,path.basename(dir));
        }
        fs.mkdir(dir,mode,function(err){
            if(err !== null){
                if( err.code === 'EEXIST'
                 && err.path === dir){
                    // make sure the directory really does exist
                    fs.stat(dir,function(staterr,stat){
                        // as mkdirP guys say, this is very strange
                        if(staterr || !stat.isDirectory()){
                            if(cb) cb(err);
                        }
                        if(cb) cb(null,dir);
                        return null;
                        // if the stat is good, do nothing.  some other processed did it
                    });

                }else{
                    console.log(err);
                    throw new Error(err);
                }
            }else{
                if(cb) cb(null,dir);
            }
            return 1;

        });
    };
    return callback;
}
function makeme (dir,mode,cb){

    var callback = function(err,parent){
        //console.log('makeme: ',dir)
        if(err) throw new Error(err)
        if(parent){
            // replace root of dir with parent
            dir = path.join(parent,path.basename(dir));
        }
        fs.mkdir(dir,mode,function(err){
            if(err !== null){
                if( err.code === 'EEXIST'
                 && err.path === dir){
                    // make sure the directory really does exist
                    fs.stat(dir,function(staterr,stat){
                        // as mkdirP guys say, this is very strange
                        if(staterr || !stat.isDirectory()){
                            if(cb) cb(err);
                        }
                        if(cb) cb(null,dir);
                        return null;
                        // if the stat is good, do nothing.  some other processed did it
                    });

                }else{
                    console.log(err);
                    throw new Error(err);
                }
            }else{
                if(cb) cb(null,dir);
            }
            return 1;

        });
    };
    return callback;
}
function makeme ( dir , mode , cb ) { var callback = function ( err , parent ) { //console.log('makeme: ',dir) if ( err ) throw new Error ( err ) if ( parent ) { // replace root of dir with parent dir = path . join ( parent , path . basename ( dir ) ) ; } fs . mkdir ( dir , mode , function ( err ) { if ( err !== null ) { if ( err . code === 'EEXIST' && err . path === dir ) { // make sure the directory really does exist fs . stat ( dir , function ( staterr , stat ) { // as mkdirP guys say, this is very strange if ( staterr || ! stat . isDirectory ( ) ) { if ( cb ) cb ( err ) ; } if ( cb ) cb ( null , dir ) ; return null ; // if the stat is good, do nothing.  some other processed did it } ) ; } else { console . log ( err ) ; throw new Error ( err ) ; } } else { if ( cb ) cb ( null , dir ) ; } return 1 ; } ) ; } ; return callback ; }
do the actual directory making.  probably should add mode as a parameter somewhere
do the actual directory making . probably should add mode as a parameter somewhere