lib/core/tasks.js
function(node) {

    if (isTask(node)) {

      // This is a task so do nothing.
      return [node];

    } else if (isBranch(node)) {

      // Concat map children with a recMap.
      node.children = _.flatten(_.map(node.children, recMap));

      // Sort children.
      node.children.sort(compareBranchOrTask);

      // Resolve duplicate named children.
      // Group children by name.
      var nameMap = _.groupBy(node.children, getName);

      // Resolve conflicts.
      node.children = _.map(_.values(nameMap), function(children) {

        if (children.length === 1) {

          // No conflicts so just return head of array.
          return children[0];

        } else {

          // Resolve conflict by finding a single node with the override flag.
          var overrides = _.filter(children, function(child) {
            return child.__override;
          });

          if (overrides.length === 1) {

            // Conflict resolved.
            return overrides[0];

          } else {

            // Conflict can not be resolved, throw an error.
            throw new Error('Conflicting task names can not be resolved: ' +
              pp(children));

          }

        }

      });

      if (getName(node) === appName) {

        // Replace this node with this nodes children.
        _.each(node.children, function(child) {
          // Mark each child with an override flag so we can resolve conflicts.
          child.__override = true;
        });
        return node.children;

      } else {

        // Just return.
        return [node];

      }

    } else {

      // This should never happen.
      assert(false);

    }

  }
function(node) {

    if (isTask(node)) {

      // This is a task so do nothing.
      return [node];

    } else if (isBranch(node)) {

      // Concat map children with a recMap.
      node.children = _.flatten(_.map(node.children, recMap));

      // Sort children.
      node.children.sort(compareBranchOrTask);

      // Resolve duplicate named children.
      // Group children by name.
      var nameMap = _.groupBy(node.children, getName);

      // Resolve conflicts.
      node.children = _.map(_.values(nameMap), function(children) {

        if (children.length === 1) {

          // No conflicts so just return head of array.
          return children[0];

        } else {

          // Resolve conflict by finding a single node with the override flag.
          var overrides = _.filter(children, function(child) {
            return child.__override;
          });

          if (overrides.length === 1) {

            // Conflict resolved.
            return overrides[0];

          } else {

            // Conflict can not be resolved, throw an error.
            throw new Error('Conflicting task names can not be resolved: ' +
              pp(children));

          }

        }

      });

      if (getName(node) === appName) {

        // Replace this node with this nodes children.
        _.each(node.children, function(child) {
          // Mark each child with an override flag so we can resolve conflicts.
          child.__override = true;
        });
        return node.children;

      } else {

        // Just return.
        return [node];

      }

    } else {

      // This should never happen.
      assert(false);

    }

  }
function ( node ) { if ( isTask ( node ) ) { // This is a task so do nothing. return [ node ] ; } else if ( isBranch ( node ) ) { // Concat map children with a recMap. node . children = _ . flatten ( _ . map ( node . children , recMap ) ) ; // Sort children. node . children . sort ( compareBranchOrTask ) ; // Resolve duplicate named children. // Group children by name. var nameMap = _ . groupBy ( node . children , getName ) ; // Resolve conflicts. node . children = _ . map ( _ . values ( nameMap ) , function ( children ) { if ( children . length === 1 ) { // No conflicts so just return head of array. return children [ 0 ] ; } else { // Resolve conflict by finding a single node with the override flag. var overrides = _ . filter ( children , function ( child ) { return child . __override ; } ) ; if ( overrides . length === 1 ) { // Conflict resolved. return overrides [ 0 ] ; } else { // Conflict can not be resolved, throw an error. throw new Error ( 'Conflicting task names can not be resolved: ' + pp ( children ) ) ; } } } ) ; if ( getName ( node ) === appName ) { // Replace this node with this nodes children. _ . each ( node . children , function ( child ) { // Mark each child with an override flag so we can resolve conflicts. child . __override = true ; } ) ; return node . children ; } else { // Just return. return [ node ] ; } } else { // This should never happen. assert ( false ) ; } }
Recursively map branch to get the cli look we want.
Recursively map branch to get the cli look we want .