node_modules/grunt-angular-builder/tasks/middleware/buildAssets.js
/**
 * Exports the assets required by the application's modules.
 * @constructor
 * @implements {MiddlewareInterface}
 * @param {Context} context The execution context for the middleware stack.
 */
Exports the assets required by the application's modules.
@constructor
@implements {MiddlewareInterface}
@param {Context} context The execution context for the middleware stack.
Exports the assets required by the application ' s modules . @constructor @implements { MiddlewareInterface } @param { Context } context The execution context for the middleware stack .
function BuildAssetsMiddleware (context)
{
  var grunt = context.grunt
    , options = context.options.assets;
  var exportedAssets = {};
  this.analyze = function (filesArray)
  {
  };
  this.trace = function (module)
  {
    .
  };
  this.build = function (targetScript)
  {
    if (!options.enabled) return;
    var stylehseets = grunt.config (context.options.requiredStylesheets.exportToConfigProperty);
    if (!stylehseets) return; 
    var targetPath = path.dirname (targetScript);
    stylehseets.forEach (function (filePath)
    {
      var src = grunt.file.read (filePath);
      scan (path.dirname (filePath), targetPath, src);
    });
  };
  function scan (basePath, targetPath, sourceCode)
  {
    var match;
    while ((match = MATCH_URLS.exec (sourceCode))) {
      var url = match[2];
      if (!url.match (/^http/i) && url[0] !== '/') { 
        var absSrcPath = path.resolve (basePath, url)
          , absDestPath = path.resolve (targetPath, options.targetDir, url)
          , relDestPath = path.relative (targetPath, absDestPath);
        if (relDestPath[0] === '.')
          return util.warn ('Relative asset url falls outside the build folder: <cyan>%</cyan>%', url, util.NL);
        if (exportedAssets[absDestPath]) 
          continue;
        else exportedAssets[absDestPath] = true;
        var absTargetFolder = path.dirname (absDestPath);
        grunt.file.mkdir (absTargetFolder);
        if (options.symlink)
          fs.symlinkSync (absSrcPath, absDestPath);
        else grunt.file.copy (absSrcPath, absDestPath);
      }
    }
  }
}
function BuildAssetsMiddleware ( context ) { var grunt = context . grunt , options = context . options . assets ; var exportedAssets = { } ; this . analyze = function ( filesArray ) { } ; this . trace = function ( module ) { } ; this . build = function ( targetScript ) { if ( ! options . enabled ) return ; var stylehseets = grunt . config ( context . options . requiredStylesheets . exportToConfigProperty ) ; if ( ! stylehseets ) return ; var targetPath = path . dirname ( targetScript ) ; stylehseets . forEach ( function ( filePath ) { var src = grunt . file . read ( filePath ) ; scan ( path . dirname ( filePath ) , targetPath , src ) ; } ) ; } ; function scan ( basePath , targetPath , sourceCode ) { var match ; while ( ( match = MATCH_URLS . exec ( sourceCode ) ) ) { var url = match [ 2 ] ; if ( ! url . match ( / ^http / i ) && url [ 0 ] !== '/' ) { var absSrcPath = path . resolve ( basePath , url ) , absDestPath = path . resolve ( targetPath , options . targetDir , url ) , relDestPath = path . relative ( targetPath , absDestPath ) ; if ( relDestPath [ 0 ] === '.' ) return util . warn ( 'Relative asset url falls outside the build folder: <cyan>%</cyan>%' , url , util . NL ) ; if ( exportedAssets [ absDestPath ] ) continue ; else exportedAssets [ absDestPath ] = true ; var absTargetFolder = path . dirname ( absDestPath ) ; grunt . file . mkdir ( absTargetFolder ) ; if ( options . symlink ) fs . symlinkSync ( absSrcPath , absDestPath ) ; else grunt . file . copy ( absSrcPath , absDestPath ) ; } } } }
Exports the assets required by the application's modules.
Exports the assets required by the application ' s modules .
/**
   * Records which files have been already exported.
   * Prevents duplicate asset exports.
   * It's a map of absolute file names to boolean `true`.
   * @type {Object.<string,boolean>}
   */ //-------------------------------------------------------------------------------------------------------------------- // PUBLIC API //-------------------------------------------------------------------------------------------------------------------- /* jshint unused: vars */ // Do nothing /* jshint unused: vars */ // Do nothing. // Import file paths. // No stylesheet sources are configured. //-------------------------------------------------------------------------------------------------------------------- // PRIVATE //-------------------------------------------------------------------------------------------------------------------- /**
   * Scans a stylesheet for asset URL references and copies the assets to the build folder.
   * @private
   * @param {string} basePath
   * @param {string} targetPath
   * @param {string} sourceCode
   */ // Skip absolute URLs // skip already exported asset