tasks/middleware/overrideDependencies.js
function OverrideDependenciesMiddleware (context)
{
  /* jshint unused: vars */
  var options = context.options.overrideDependencies
    , enabled = options.dependencies && options.dependencies.length;

  //--------------------------------------------------------------------------------------------------------------------
  // PUBLIC API
  //--------------------------------------------------------------------------------------------------------------------

  this.analyze = function (filesArray)
  {
    /* jshint unused: vars */
    if (!enabled) return;

    var mainModuleName = context.options.mainModule;
    var mainModule = context.modules[mainModuleName] = new ModuleDef (mainModuleName);
    mainModule.requires = options.dependencies;
    // Must set head to a non-empty string to mark the module as being initialized.
    mainModule.head = ' ';
  };

  this.trace = function (module)
  {
    /* jshint unused: vars */
  };

  this.build = function (targetScript)
  {
    /* jshint unused: vars */
    if (!enabled) return;

    if (context.options.debugBuild && context.options.debugBuild.enabled) {
      var declaration = sprintf ("angular.module('%',%);",
        context.options.mainModule,
        util.toQuotedList (options.dependencies)
      );
      context.appendOutput += sprintf ('<script>%</script>', declaration);
    }
  };
}
function OverrideDependenciesMiddleware (context)
{
  /* jshint unused: vars */
  var options = context.options.overrideDependencies
    , enabled = options.dependencies && options.dependencies.length;

  //--------------------------------------------------------------------------------------------------------------------
  // PUBLIC API
  //--------------------------------------------------------------------------------------------------------------------

  this.analyze = function (filesArray)
  {
    /* jshint unused: vars */
    if (!enabled) return;

    var mainModuleName = context.options.mainModule;
    var mainModule = context.modules[mainModuleName] = new ModuleDef (mainModuleName);
    mainModule.requires = options.dependencies;
    // Must set head to a non-empty string to mark the module as being initialized.
    mainModule.head = ' ';
  };

  this.trace = function (module)
  {
    /* jshint unused: vars */
  };

  this.build = function (targetScript)
  {
    /* jshint unused: vars */
    if (!enabled) return;

    if (context.options.debugBuild && context.options.debugBuild.enabled) {
      var declaration = sprintf ("angular.module('%',%);",
        context.options.mainModule,
        util.toQuotedList (options.dependencies)
      );
      context.appendOutput += sprintf ('<script>%</script>', declaration);
    }
  };
}
function OverrideDependenciesMiddleware ( context ) { /* jshint unused: vars */ var options = context . options . overrideDependencies , enabled = options . dependencies && options . dependencies . length ; //-------------------------------------------------------------------------------------------------------------------- // PUBLIC API //-------------------------------------------------------------------------------------------------------------------- this . analyze = function ( filesArray ) { /* jshint unused: vars */ if ( ! enabled ) return ; var mainModuleName = context . options . mainModule ; var mainModule = context . modules [ mainModuleName ] = new ModuleDef ( mainModuleName ) ; mainModule . requires = options . dependencies ; // Must set head to a non-empty string to mark the module as being initialized. mainModule . head = ' ' ; } ; this . trace = function ( module ) { /* jshint unused: vars */ } ; this . build = function ( targetScript ) { /* jshint unused: vars */ if ( ! enabled ) return ; if ( context . options . debugBuild && context . options . debugBuild . enabled ) { var declaration = sprintf ( "angular.module('%',%);" , context . options . mainModule , util . toQuotedList ( options . dependencies ) ) ; context . appendOutput += sprintf ( '<script>%</script>' , declaration ) ; } } ; }
Allows the setting of the main module's dependencies via Grunt configuration options and synthetizes that module's
declaration javascript code.
@constructor
@implements {MiddlewareInterface}
@param {Context} context The execution context for the middleware stack.
Allows the setting of the main module s dependencies via Grunt configuration options and synthetizes that module s declaration javascript code .