lib/gitsync.js
function _ensureExists(dir, callback) {
    dir = path.resolve(dir); // make full path
    
    path.exists(dir, function(exists) {
        if (!exists) {
            // ensure that the parent dir exists
            _ensureExists(path.dirname(dir), function(err) {
                if (err) {
                    callback(err);
                    return;
                }
                
                // make the dir
                log.log('Creating ' + dir);
                fs.mkdir(dir, function(err) {
                    if (err) {
                        callback(err);
                        return;
                    }
                    
                    callback(null);
                });
            });
        }
        else {
            callback(null);
        }
    });
}
function _ensureExists(dir, callback) {
    dir = path.resolve(dir); // make full path
    
    path.exists(dir, function(exists) {
        if (!exists) {
            // ensure that the parent dir exists
            _ensureExists(path.dirname(dir), function(err) {
                if (err) {
                    callback(err);
                    return;
                }
                
                // make the dir
                log.log('Creating ' + dir);
                fs.mkdir(dir, function(err) {
                    if (err) {
                        callback(err);
                        return;
                    }
                    
                    callback(null);
                });
            });
        }
        else {
            callback(null);
        }
    });
}
function _ensureExists ( dir , callback ) { dir = path . resolve ( dir ) ; // make full path path . exists ( dir , function ( exists ) { if ( ! exists ) { // ensure that the parent dir exists _ensureExists ( path . dirname ( dir ) , function ( err ) { if ( err ) { callback ( err ) ; return ; } // make the dir log . log ( 'Creating ' + dir ) ; fs . mkdir ( dir , function ( err ) { if ( err ) { callback ( err ) ; return ; } callback ( null ) ; } ) ; } ) ; } else { callback ( null ) ; } } ) ; }
Ensures that a directory exists. If it doesn't, creates it and it's parents if needed.
Ensures that a directory exists . If it doesn t creates it and it s parents if needed .