tasks/motion_build.js
function(filepath, data){
      filepath = [].concat(filepath);
      var buf=[].concat(filepath);
      function parse(fileId, refUri, data) {
        var filepath = id2Uri(fileId, refUri, data);
        if(!grunt.file.exists(filepath)){ //file not found
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return;
        }
        buf.unshift(filepath);
        if(filepath.indexOf('.css') != -1){ //if depend a css file
          buf.unshift(CSSFILE_HOLDER);
          return;
        }

        var dependencies = parseDependencies(grunt.file.read(filepath));
        if (dependencies.length) {
          var i = dependencies.length;
          while (i--) {
            parse(dependencies[i], filepath, data);
          }
        }
      }
      filepath.forEach(function(filepath){
        var fileContent = grunt.file.read(filepath);
        parseDependencies(fileContent).forEach(function(id){
          parse(id, filepath, data);
        })
      })
      //filter the same file
      return buf.filter(function(value, index, self){
        return self.indexOf(value) === index;
      });
  }
function(filepath, data){
      filepath = [].concat(filepath);
      var buf=[].concat(filepath);
      function parse(fileId, refUri, data) {
        var filepath = id2Uri(fileId, refUri, data);
        if(!grunt.file.exists(filepath)){ //file not found
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return;
        }
        buf.unshift(filepath);
        if(filepath.indexOf('.css') != -1){ //if depend a css file
          buf.unshift(CSSFILE_HOLDER);
          return;
        }

        var dependencies = parseDependencies(grunt.file.read(filepath));
        if (dependencies.length) {
          var i = dependencies.length;
          while (i--) {
            parse(dependencies[i], filepath, data);
          }
        }
      }
      filepath.forEach(function(filepath){
        var fileContent = grunt.file.read(filepath);
        parseDependencies(fileContent).forEach(function(id){
          parse(id, filepath, data);
        })
      })
      //filter the same file
      return buf.filter(function(value, index, self){
        return self.indexOf(value) === index;
      });
  }
function ( filepath , data ) { filepath = [ ] . concat ( filepath ) ; var buf = [ ] . concat ( filepath ) ; function parse ( fileId , refUri , data ) { var filepath = id2Uri ( fileId , refUri , data ) ; if ( ! grunt . file . exists ( filepath ) ) { //file not found grunt . log . warn ( 'Source file "' + filepath + '" not found.' ) ; return ; } buf . unshift ( filepath ) ; if ( filepath . indexOf ( '.css' ) != - 1 ) { //if depend a css file buf . unshift ( CSSFILE_HOLDER ) ; return ; } var dependencies = parseDependencies ( grunt . file . read ( filepath ) ) ; if ( dependencies . length ) { var i = dependencies . length ; while ( i -- ) { parse ( dependencies [ i ] , filepath , data ) ; } } } filepath . forEach ( function ( filepath ) { var fileContent = grunt . file . read ( filepath ) ; parseDependencies ( fileContent ) . forEach ( function ( id ) { parse ( id , filepath , data ) ; } ) } ) //filter the same file return buf . filter ( function ( value , index , self ) { return self . indexOf ( value ) === index ; } ) ; }
get all dependencies by one file path
@param  {String} filepath file path
@return {Array}          dependencies list
get all dependencies by one file path