index.js
function(name, options) {
        if (typeof name === 'function') {
          this.use(name, options);
          return this;
        }

        if (Array.isArray(name)) {
          var len = name.length;
          var idx = -1;
          while (++idx < len) {
            this.extendWith(name[idx], options);
          }
          return this;
        }

        var app = name;
        if (typeof name === 'string') {
          app = this.generators[name] || this.findGenerator(name, options);
          if (!app && utils.exists(name)) {
            var fn = utils.tryRequire(name, this.cwd);
            if (typeof fn === 'function') {
              app = this.register(name, fn);
            }
          }
        }

        if (!utils.isValidInstance(app)) {
          throw new Error('cannot find generator: "' + name + '"');
        }

        var alias = app.env ? app.env.alias : 'default';
        debug('extending "%s" with "%s"', alias, name);
        app.run(this);
        app.invoke(options, this);
        return this;
      }
function(name, options) {
        if (typeof name === 'function') {
          this.use(name, options);
          return this;
        }

        if (Array.isArray(name)) {
          var len = name.length;
          var idx = -1;
          while (++idx < len) {
            this.extendWith(name[idx], options);
          }
          return this;
        }

        var app = name;
        if (typeof name === 'string') {
          app = this.generators[name] || this.findGenerator(name, options);
          if (!app && utils.exists(name)) {
            var fn = utils.tryRequire(name, this.cwd);
            if (typeof fn === 'function') {
              app = this.register(name, fn);
            }
          }
        }

        if (!utils.isValidInstance(app)) {
          throw new Error('cannot find generator: "' + name + '"');
        }

        var alias = app.env ? app.env.alias : 'default';
        debug('extending "%s" with "%s"', alias, name);
        app.run(this);
        app.invoke(options, this);
        return this;
      }
function ( name , options ) { if ( typeof name === 'function' ) { this . use ( name , options ) ; return this ; } if ( Array . isArray ( name ) ) { var len = name . length ; var idx = - 1 ; while ( ++ idx < len ) { this . extendWith ( name [ idx ] , options ) ; } return this ; } var app = name ; if ( typeof name === 'string' ) { app = this . generators [ name ] || this . findGenerator ( name , options ) ; if ( ! app && utils . exists ( name ) ) { var fn = utils . tryRequire ( name , this . cwd ) ; if ( typeof fn === 'function' ) { app = this . register ( name , fn ) ; } } } if ( ! utils . isValidInstance ( app ) ) { throw new Error ( 'cannot find generator: "' + name + '"' ) ; } var alias = app . env ? app . env . alias : 'default' ; debug ( 'extending "%s" with "%s"' , alias , name ) ; app . run ( this ) ; app . invoke ( options , this ) ; return this ; }
Extend the generator instance with settings and features
of another generator.

```js
var foo = base.generator('foo');
app.extendWith(foo);
// or
app.extendWith('foo');
// or
app.extendWith(['foo', 'bar', 'baz']);

app.extendWith(require('generate-defaults'));
```

@name .extendWith
@param {String|Object} `app`
@return {Object} Returns the instance for chaining.
@api public
Extend the generator instance with settings and features of another generator .