node_modules/grunt-angular-builder/tasks/middleware/includeRequiredScripts.js
/**
   * Extracts file paths from embedded comment references to scripts and appends them to `paths`.
   * @param {string} sourceCode
   * @param {string} filePath
   */
Extracts file paths from embedded comment references to scripts and appends them to `paths`.
@param {string} sourceCode
@param {string} filePath
Extracts file paths from embedded comment references to scripts and appends them to ` paths ` . @param { string } sourceCode @param { string } filePath
function scan (sourceCode, filePath)
  {
    var match
      , r = new RegExp (MATCH_DIRECTIVE);
    while ((match = r.exec (sourceCode))) {
      match[1].split (/\s*,\s*/).forEach (function (s)
      {
        var m = s.match (/(["'])(.*?)\1/);
        if (!m)
          util.warn ('syntax error on #script directive on argument ...<cyan> % </cyan>...%At <cyan>%</cyan>\t',
            s, util.NL, filePath);
        else {
          var url = m[2];
          var requiredPath = path.normalize (path.dirname (filePath) + '/' + url);
          if (!references[requiredPath]) {
            references[requiredPath] = true;
            var source = context.grunt.file.read (requiredPath);
            scan (source, requiredPath);
            paths.push (requiredPath);
            sources.push (source);
          }
        }
      });
    }
  }
function scan ( sourceCode , filePath ) { var match , r = new RegExp ( MATCH_DIRECTIVE ) ; while ( ( match = r . exec ( sourceCode ) ) ) { match [ 1 ] . split ( / \s*,\s* / ) . forEach ( function ( s ) { var m = s . match ( / (["'])(.*?)\1 / ) ; if ( ! m ) util . warn ( 'syntax error on #script directive on argument ...<cyan> % </cyan>...%At <cyan>%</cyan>\t' , s , util . NL , filePath ) ; else { var url = m [ 2 ] ; var requiredPath = path . normalize ( path . dirname ( filePath ) + '/' + url ) ; if ( ! references [ requiredPath ] ) { references [ requiredPath ] = true ; var source = context . grunt . file . read ( requiredPath ) ; scan ( source , requiredPath ) ; paths . push ( requiredPath ) ; sources . push ( source ) ; } } } ) ; } }
Extracts file paths from embedded comment references to scripts and appends them to `paths`.
Extracts file paths from embedded comment references to scripts and appends them to ` paths ` .
/* jshint -W083 */ // Check if this script was not already referenced. // First, see if the required script has its own 'requires'. // If so, they must be required *before* the current script. // Let's register the dependency now.