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

    if (payload.length === 0) {

      // Reached end of argv path, so return current node.
      node.argv = {
        payload: payload,
        options: argv.options,
        rawOptions: argv.rawOptions
      };
      return node;

    } else if (isTask(node)) {

      // A task has been found along the argv path, so return it.
      node.argv = {
        payload: payload,
        options: argv.options,
        rawOptions: argv.rawOptions
      };
      return node;

    } else if (isBranch(node)) {

      // Get the head of the argv path.
      var hd = payload[0];
      var tl = payload.slice(1);

      // Find a child of node branch that matches hd.
      var child = findChild(node, hd);

      if (child) {

        // Update the argv path and then recurse with child that was found.
        return rec(child, tl);

      } else {

        // No matching child was found, it's a dead search so return null.
        return null;

      }

    } else {

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

    }

  }
function(node, payload) {

    if (payload.length === 0) {

      // Reached end of argv path, so return current node.
      node.argv = {
        payload: payload,
        options: argv.options,
        rawOptions: argv.rawOptions
      };
      return node;

    } else if (isTask(node)) {

      // A task has been found along the argv path, so return it.
      node.argv = {
        payload: payload,
        options: argv.options,
        rawOptions: argv.rawOptions
      };
      return node;

    } else if (isBranch(node)) {

      // Get the head of the argv path.
      var hd = payload[0];
      var tl = payload.slice(1);

      // Find a child of node branch that matches hd.
      var child = findChild(node, hd);

      if (child) {

        // Update the argv path and then recurse with child that was found.
        return rec(child, tl);

      } else {

        // No matching child was found, it's a dead search so return null.
        return null;

      }

    } else {

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

    }

  }
function ( node , payload ) { if ( payload . length === 0 ) { // Reached end of argv path, so return current node. node . argv = { payload : payload , options : argv . options , rawOptions : argv . rawOptions } ; return node ; } else if ( isTask ( node ) ) { // A task has been found along the argv path, so return it. node . argv = { payload : payload , options : argv . options , rawOptions : argv . rawOptions } ; return node ; } else if ( isBranch ( node ) ) { // Get the head of the argv path. var hd = payload [ 0 ] ; var tl = payload . slice ( 1 ) ; // Find a child of node branch that matches hd. var child = findChild ( node , hd ) ; if ( child ) { // Update the argv path and then recurse with child that was found. return rec ( child , tl ) ; } else { // No matching child was found, it's a dead search so return null. return null ; } } else { // This should never happen. assert ( false ) ; } }
Recursive function for searching the task tree.
Recursive function for searching the task tree .