lib/fsExt.js
function existsOrCreateSync(filePath, opts){
    opts = opts || {};
    opts.encoding = opts.encoding || 'utf8';
    opts.data = opts.data || opts.content || '';
    opts.mode = opts.mode || '0777';
    
    var fp = resolve(filePath);
    var isFile = opts.hasOwnProperty('isFile') ? opts.isFile : !!fp.extName;
    
    var exists = fs.existsSync(fp.fullPath);
    if(!exists || opts.replace){
        mkdir((isFile ? fp.dirName : fp.fullPath));
        if(isFile || opts.replace) fs.writeFileSync(fp.fullPath, opts.data, opts.encoding);
    }
    
    function mkdir(fullPath){
        if(fs.existsSync(fullPath)) return;
        else {
            var parentPath = fullPath.split('/');
            parentPath.pop();
            mkdir(parentPath.join('/'));
            fs.mkdirSync(fullPath, opts.mode);
        }
    }
    
    return exists;
}
function existsOrCreateSync(filePath, opts){
    opts = opts || {};
    opts.encoding = opts.encoding || 'utf8';
    opts.data = opts.data || opts.content || '';
    opts.mode = opts.mode || '0777';
    
    var fp = resolve(filePath);
    var isFile = opts.hasOwnProperty('isFile') ? opts.isFile : !!fp.extName;
    
    var exists = fs.existsSync(fp.fullPath);
    if(!exists || opts.replace){
        mkdir((isFile ? fp.dirName : fp.fullPath));
        if(isFile || opts.replace) fs.writeFileSync(fp.fullPath, opts.data, opts.encoding);
    }
    
    function mkdir(fullPath){
        if(fs.existsSync(fullPath)) return;
        else {
            var parentPath = fullPath.split('/');
            parentPath.pop();
            mkdir(parentPath.join('/'));
            fs.mkdirSync(fullPath, opts.mode);
        }
    }
    
    return exists;
}
function existsOrCreateSync ( filePath , opts ) { opts = opts || { } ; opts . encoding = opts . encoding || 'utf8' ; opts . data = opts . data || opts . content || '' ; opts . mode = opts . mode || '0777' ; var fp = resolve ( filePath ) ; var isFile = opts . hasOwnProperty ( 'isFile' ) ? opts . isFile : ! ! fp . extName ; var exists = fs . existsSync ( fp . fullPath ) ; if ( ! exists || opts . replace ) { mkdir ( ( isFile ? fp . dirName : fp . fullPath ) ) ; if ( isFile || opts . replace ) fs . writeFileSync ( fp . fullPath , opts . data , opts . encoding ) ; } function mkdir ( fullPath ) { if ( fs . existsSync ( fullPath ) ) return ; else { var parentPath = fullPath . split ( '/' ) ; parentPath . pop ( ) ; mkdir ( parentPath . join ( '/' ) ) ; fs . mkdirSync ( fullPath , opts . mode ) ; } } return exists ; }
sync version of existsOrCreate
@param {String} filePath
@param {Object}  opts     options
@returns {Boolean} exists
sync version of existsOrCreate