'use strict';

var path = require('path');
var resolveUp = require('resolve-up');
var reduce = require('lodash')._.reduce;

/**
 * Load generators onto the `generators` object
 */

module.exports = function generators_() {
  this.generators = this.generators || {};
  var pattern = this.option('generator pattern') || 'generate-*';

  reduce(resolveUp(pattern), function (acc, dir) {
    var json = require(path.resolve(dir, 'package.json'));
    if (!json.main) return acc;

    var fp = path.resolve(dir, json.main);
    acc[path.basename(dir)] = require(path.resolve(fp));
    return acc;
  }, this.generators);
};

@@ -12,20 +12,25 @@
 ';%0A%0Avar 
-path
+resolveUp
  = requi
@@ -37,29 +37,30 @@
 re('
-path');%0Avar resolveUp
+resolve-up');%0Avar path
  = r
@@ -67,34 +67,28 @@
 equire('
-resolve-up
+path
 ');%0Avar 
 reduce =
@@ -79,22 +79,17 @@
 ');%0Avar 
-reduce
+_
  = requi
@@ -104,17 +104,8 @@
 sh')
-._.reduce
 ;%0A%0A/
@@ -314,16 +314,18 @@
 -*';%0A%0A  
+_.
 reduce(r
@@ -500,16 +500,16 @@
 .main);%0A
-
     acc%5B
@@ -529,32 +529,40 @@
 (dir)%5D = require
+.resolve
 (path.resolve(fp

use `require.resolve` so the generator can be called elsewhere