index.js
function(name, options) {
        var opts = utils.merge({}, this.options, options);
        var config;

        switch (utils.typeOf(name)) {
          case 'function':
            config = name;
            break;
          case 'object':
            config = name;
            name = config.name;
            break;
          case 'string':
          default: {
            opts.name = name;
            config = this.scaffolds[name];
            if (typeof config === 'undefined') {
              throw new Error(`scaffold "${name}" is not registered`);
            }
            break;
          }
        }

        if (typeof config === 'function') {
          config = config(opts);
        }

        if (!utils.isObject(config)) {
          throw new TypeError('expected config to be an object');
        }

        // if `config` is not an instance of Scaffold, make it one
        if (!this.isScaffold(config)) {
          var Scaffold = this.get('Scaffold');
          var scaffold = new Scaffold(opts);
          scaffold.options = utils.merge({}, this.options, scaffold.options, options);
          if (typeof name === 'string') {
            scaffold.name = name;
          }
          if (typeof this.run === 'function') {
            this.run(scaffold);
          }
          this.emit('scaffold', scaffold);
          scaffold.on('target', this.emit.bind(this, 'target'));
          config = scaffold.addTargets(config);
        }

        // otherwise, ensure options are merged onto the scaffold,
        // and all targets are emitted
        else {
          config.options = utils.merge({}, this.options, config.options, options);
          if (typeof name === 'string') {
            config.name = name;
          }
          if (typeof this.run === 'function') {
            this.run(config);
          }
          for (var key in config.targets) {
            if (config.targets.hasOwnProperty(key)) {
              this.emit('target', config.targets[key]);
            }
          }
          config.on('target', this.emit.bind(this, 'target'));
          this.emit('scaffold', config);
        }
        return config;
      }
function(name, options) {
        var opts = utils.merge({}, this.options, options);
        var config;

        switch (utils.typeOf(name)) {
          case 'function':
            config = name;
            break;
          case 'object':
            config = name;
            name = config.name;
            break;
          case 'string':
          default: {
            opts.name = name;
            config = this.scaffolds[name];
            if (typeof config === 'undefined') {
              throw new Error(`scaffold "${name}" is not registered`);
            }
            break;
          }
        }

        if (typeof config === 'function') {
          config = config(opts);
        }

        if (!utils.isObject(config)) {
          throw new TypeError('expected config to be an object');
        }

        // if `config` is not an instance of Scaffold, make it one
        if (!this.isScaffold(config)) {
          var Scaffold = this.get('Scaffold');
          var scaffold = new Scaffold(opts);
          scaffold.options = utils.merge({}, this.options, scaffold.options, options);
          if (typeof name === 'string') {
            scaffold.name = name;
          }
          if (typeof this.run === 'function') {
            this.run(scaffold);
          }
          this.emit('scaffold', scaffold);
          scaffold.on('target', this.emit.bind(this, 'target'));
          config = scaffold.addTargets(config);
        }

        // otherwise, ensure options are merged onto the scaffold,
        // and all targets are emitted
        else {
          config.options = utils.merge({}, this.options, config.options, options);
          if (typeof name === 'string') {
            config.name = name;
          }
          if (typeof this.run === 'function') {
            this.run(config);
          }
          for (var key in config.targets) {
            if (config.targets.hasOwnProperty(key)) {
              this.emit('target', config.targets[key]);
            }
          }
          config.on('target', this.emit.bind(this, 'target'));
          this.emit('scaffold', config);
        }
        return config;
      }
function ( name , options ) { var opts = utils . merge ( { } , this . options , options ) ; var config ; switch ( utils . typeOf ( name ) ) { case 'function' : config = name ; break ; case 'object' : config = name ; name = config . name ; break ; case 'string' : default : { opts . name = name ; config = this . scaffolds [ name ] ; if ( typeof config === 'undefined' ) { throw new Error ( ` ${ name } ` ) ; } break ; } } if ( typeof config === 'function' ) { config = config ( opts ) ; } if ( ! utils . isObject ( config ) ) { throw new TypeError ( 'expected config to be an object' ) ; } // if `config` is not an instance of Scaffold, make it one if ( ! this . isScaffold ( config ) ) { var Scaffold = this . get ( 'Scaffold' ) ; var scaffold = new Scaffold ( opts ) ; scaffold . options = utils . merge ( { } , this . options , scaffold . options , options ) ; if ( typeof name === 'string' ) { scaffold . name = name ; } if ( typeof this . run === 'function' ) { this . run ( scaffold ) ; } this . emit ( 'scaffold' , scaffold ) ; scaffold . on ( 'target' , this . emit . bind ( this , 'target' ) ) ; config = scaffold . addTargets ( config ) ; } // otherwise, ensure options are merged onto the scaffold, // and all targets are emitted else { config . options = utils . merge ( { } , this . options , config . options , options ) ; if ( typeof name === 'string' ) { config . name = name ; } if ( typeof this . run === 'function' ) { this . run ( config ) ; } for ( var key in config . targets ) { if ( config . targets . hasOwnProperty ( key ) ) { this . emit ( 'target' , config . targets [ key ] ) ; } } config . on ( 'target' , this . emit . bind ( this , 'target' ) ) ; this . emit ( 'scaffold' , config ) ; } return config ; }
Get scaffold `name` from `app.scaffolds`, or return a normalized
instance of `Scaffold` if an object or function is passed.

```js
var scaffold = app.getScaffold('foo');

// or create an instance of `Scaffold` using the given object
var scaffold = app.getScaffold({
docs: {
options: {},
files: {
src: ['*'],
dest: 'foo'
}
}
});
```
@param {String} `name`
@param {Object} `options`
@api public
Get scaffold name from app . scaffolds or return a normalized instance of Scaffold if an object or function is passed .