lib/cache.js
function(config){
    _logger.info('begin dump files ...');
    var map = {};
    ['fileInclude','fileExclude'].forEach(function(name){
        var value = config[name];
        if (!!value){
            if (typeof value==='string'){
                var reg = new RegExp(value,'i');
                config[name] = function(file){
                    return reg.test(file);
                };
            }else if(!!value.test){
                config[name] = function(file){
                    return value.test(file);
                }
            }
        }
        if (!_util.isFunction(config[name])){
            var flag = name!=='fileExclude';
            config[name] = function(file){
                return flag;
            };
        }
    });
    (config.resRoot||'').split(',').forEach(function(dir){
        if (!dir){
            return;
        }
        var ret = _fs.lsfile(dir,function(name,file){
            return !config.fileExclude(file)&&
                config.fileInclude(file);
        });
        ret.forEach(function(v){
            map[v] = v.replace(config.webRoot,config.temp);
        });
    });
    _logger.debug('package file map -> %j',map);
    Object.keys(map).forEach(function(src){
        var dst = map[src];
        _fs.copy(src,dst,function(a){
            _logger.info('copy file %s',a);
        });
    });
}
function(config){
    _logger.info('begin dump files ...');
    var map = {};
    ['fileInclude','fileExclude'].forEach(function(name){
        var value = config[name];
        if (!!value){
            if (typeof value==='string'){
                var reg = new RegExp(value,'i');
                config[name] = function(file){
                    return reg.test(file);
                };
            }else if(!!value.test){
                config[name] = function(file){
                    return value.test(file);
                }
            }
        }
        if (!_util.isFunction(config[name])){
            var flag = name!=='fileExclude';
            config[name] = function(file){
                return flag;
            };
        }
    });
    (config.resRoot||'').split(',').forEach(function(dir){
        if (!dir){
            return;
        }
        var ret = _fs.lsfile(dir,function(name,file){
            return !config.fileExclude(file)&&
                config.fileInclude(file);
        });
        ret.forEach(function(v){
            map[v] = v.replace(config.webRoot,config.temp);
        });
    });
    _logger.debug('package file map -> %j',map);
    Object.keys(map).forEach(function(src){
        var dst = map[src];
        _fs.copy(src,dst,function(a){
            _logger.info('copy file %s',a);
        });
    });
}
function ( config ) { _logger . info ( 'begin dump files ...' ) ; var map = { } ; [ 'fileInclude' , 'fileExclude' ] . forEach ( function ( name ) { var value = config [ name ] ; if ( ! ! value ) { if ( typeof value === 'string' ) { var reg = new RegExp ( value , 'i' ) ; config [ name ] = function ( file ) { return reg . test ( file ) ; } ; } else if ( ! ! value . test ) { config [ name ] = function ( file ) { return value . test ( file ) ; } } } if ( ! _util . isFunction ( config [ name ] ) ) { var flag = name !== 'fileExclude' ; config [ name ] = function ( file ) { return flag ; } ; } } ) ; ( config . resRoot || '' ) . split ( ',' ) . forEach ( function ( dir ) { if ( ! dir ) { return ; } var ret = _fs . lsfile ( dir , function ( name , file ) { return ! config . fileExclude ( file ) && config . fileInclude ( file ) ; } ) ; ret . forEach ( function ( v ) { map [ v ] = v . replace ( config . webRoot , config . temp ) ; } ) ; } ) ; _logger . debug ( 'package file map -> %j' , map ) ; Object . keys ( map ) . forEach ( function ( src ) { var dst = map [ src ] ; _fs . copy ( src , dst , function ( a ) { _logger . info ( 'copy file %s' , a ) ; } ) ; } ) ; }
dump files to temporary directory
@param  {Object} config - config object
@return {Void}
dump files to temporary directory