function filesFilter( f, files ) {
        var cwd = f.cwd || '',
            ret = [],
            process = function( file ) {
                var fileinfo = path.join( cwd, file ),
                    dirpath = path.dirname( fileinfo ),
                    depends = [],
                    str, matches, idx;

                if ( !grunt.file.exists( fileinfo ) ) {
                    return;
                }

                ret.push( file );

                str = grunt.file.read( fileinfo );

                // 从require( dps )中找
                // 从defind( id?, dps, factory )中找
                str = str.replace( /(?:define|require)\s*\(\s*\[([^\]]+?)\],/g, function( _, m1 ) {
                    m1 = m1.replace(/\s/g, '').split(',');
                    depends = depends.concat( m1.map(function( item ) {
                        item = item.substring( 1, item.length - 1 );
                        item = item.substring(0, 1) === '.' ?
                                path.join( dirpath, item ):
                                path.join( cwd, item );

                        return path.relative( cwd, item ) + '.js';
                    }) );

                    return _;
                });

                str = str.replace( /require\s*\(\s*('|")(.+?)\1/g, function( _, m1, item ) {


                    item = item.substring(0, 1) === '.' ?
                            path.join( dirpath, item ):
                            path.join( cwd, item );

                    depends.push( path.relative( cwd, item ) + '.js' );

                    return _;
                });

                if ( depends.length ) {
                    depends = depends.filter(function( item, idx, array ) {
                        return array.indexOf( item ) === idx && grunt.file.exists( path.join( cwd, item ) );
                    });

                    idx = ret.indexOf( file );
                    [].splice.apply( ret, [ idx, 0 ].concat( depends ) );
                    depends.forEach( process );
                }
            };
        // console.log( files );
        files.forEach( process );
        ret = ret.filter(function( item, idx, arr ){
            return idx === arr.indexOf( item );
        });


        ret.unshift( path.relative( cwd, intro ) );
        ret.push( path.relative( cwd, outro ) );
        return ret;
    }
function filesFilter( f, files ) {
        var cwd = f.cwd || '',
            ret = [],
            process = function( file ) {
                var fileinfo = path.join( cwd, file ),
                    dirpath = path.dirname( fileinfo ),
                    depends = [],
                    str, matches, idx;

                if ( !grunt.file.exists( fileinfo ) ) {
                    return;
                }

                ret.push( file );

                str = grunt.file.read( fileinfo );

                // 从require( dps )中找
                // 从defind( id?, dps, factory )中找
                str = str.replace( /(?:define|require)\s*\(\s*\[([^\]]+?)\],/g, function( _, m1 ) {
                    m1 = m1.replace(/\s/g, '').split(',');
                    depends = depends.concat( m1.map(function( item ) {
                        item = item.substring( 1, item.length - 1 );
                        item = item.substring(0, 1) === '.' ?
                                path.join( dirpath, item ):
                                path.join( cwd, item );

                        return path.relative( cwd, item ) + '.js';
                    }) );

                    return _;
                });

                str = str.replace( /require\s*\(\s*('|")(.+?)\1/g, function( _, m1, item ) {


                    item = item.substring(0, 1) === '.' ?
                            path.join( dirpath, item ):
                            path.join( cwd, item );

                    depends.push( path.relative( cwd, item ) + '.js' );

                    return _;
                });

                if ( depends.length ) {
                    depends = depends.filter(function( item, idx, array ) {
                        return array.indexOf( item ) === idx && grunt.file.exists( path.join( cwd, item ) );
                    });

                    idx = ret.indexOf( file );
                    [].splice.apply( ret, [ idx, 0 ].concat( depends ) );
                    depends.forEach( process );
                }
            };
        // console.log( files );
        files.forEach( process );
        ret = ret.filter(function( item, idx, arr ){
            return idx === arr.indexOf( item );
        });


        ret.unshift( path.relative( cwd, intro ) );
        ret.push( path.relative( cwd, outro ) );
        return ret;
    }
function filesFilter ( f , files ) { var cwd = f . cwd || '' , ret = [ ] , process = function ( file ) { var fileinfo = path . join ( cwd , file ) , dirpath = path . dirname ( fileinfo ) , depends = [ ] , str , matches , idx ; if ( ! grunt . file . exists ( fileinfo ) ) { return ; } ret . push ( file ) ; str = grunt . file . read ( fileinfo ) ; // 从require( dps )中找 // 从defind( id?, dps, factory )中找 str = str . replace ( / (?:define|require)\s*\(\s*\[([^\]]+?)\], / g , function ( _ , m1 ) { m1 = m1 . replace ( / \s / g , '' ) . split ( ',' ) ; depends = depends . concat ( m1 . map ( function ( item ) { item = item . substring ( 1 , item . length - 1 ) ; item = item . substring ( 0 , 1 ) === '.' ? path . join ( dirpath , item ) : path . join ( cwd , item ) ; return path . relative ( cwd , item ) + '.js' ; } ) ) ; return _ ; } ) ; str = str . replace ( / require\s*\(\s*('|")(.+?)\1 / g , function ( _ , m1 , item ) { item = item . substring ( 0 , 1 ) === '.' ? path . join ( dirpath , item ) : path . join ( cwd , item ) ; depends . push ( path . relative ( cwd , item ) + '.js' ) ; return _ ; } ) ; if ( depends . length ) { depends = depends . filter ( function ( item , idx , array ) { return array . indexOf ( item ) === idx && grunt . file . exists ( path . join ( cwd , item ) ) ; } ) ; idx = ret . indexOf ( file ) ; [ ] . splice . apply ( ret , [ idx , 0 ] . concat ( depends ) ) ; depends . forEach ( process ) ; } } ; // console.log( files ); files . forEach ( process ) ; ret = ret . filter ( function ( item , idx , arr ) { return idx === arr . indexOf ( item ) ; } ) ; ret . unshift ( path . relative ( cwd , intro ) ) ; ret . push ( path . relative ( cwd , outro ) ) ; return ret ; }
排序，把依赖的文件移动到最上面。
排序，把依赖的文件移动到最上面。
filter files