diff --git a/lib/index.js b/lib/index.js index d049a227..ccf61bb5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -488,10 +488,10 @@ Base.prototype.run = function run(cb) { * @return {this} * * @example Using a peerDependency generator - * this.composeWith('bootstrap', { options: { sass: true } }); + * this.composeWith('bootstrap', { sass: true }); * * @example Using a direct dependency generator - * this.composeWith('bootstrap', { options: { sass: true } }, { + * this.composeWith('bootstrap', { sass: true }, { * local: require.resolve('generator-bootstrap/app/main.js') * }); */ @@ -503,21 +503,19 @@ Base.prototype.composeWith = function composeWith(namespace, options, settings) // Pass down the default options so they're correclty mirrored down the chain. options = _.extend({ - options: _.extend({ - skipInstall: this.options.skipInstall, - 'skip-install': this.options.skipInstall, - skipCache: this.options.skipCache, - 'skip-cache': this.options.skipCache - }, options.options) + skipInstall: this.options.skipInstall, + 'skip-install': this.options.skipInstall, + skipCache: this.options.skipCache, + 'skip-cache': this.options.skipCache }, options); if (settings.local) { var Generator = require(settings.local); Generator.resolved = require.resolve(settings.local); Generator.namespace = namespace; - generator = this.env.instantiate(Generator, options); + generator = this.env.instantiate(Generator, {options: options}); } else { - generator = this.env.create(namespace, options); + generator = this.env.create(namespace, {options: options}); } if (this._running) { diff --git a/test/base.js b/test/base.js index ff36ab3a..c00807d1 100644 --- a/test/base.js +++ b/test/base.js @@ -779,13 +779,12 @@ describe('Base', function () { it('pass options and arguments to the composed generators', function (done) { this.dummy.composeWith('composed:gen', { - options: { foo: 'bar', 'skip-install': true }, - arguments: ['foo'] + foo: 'bar', + 'skip-install': true }); this.dummy.run(function () { assert.equal(this.spy.firstCall.thisValue.options.foo, 'bar'); - assert.deepEqual(this.spy.firstCall.thisValue.args, ['foo']); done(); }.bind(this)); }); @@ -807,14 +806,14 @@ describe('Base', function () { }); it('pass options and arguments to the composed generators', function (done) { - this.dummy.composeWith('dumb', { - options: { foo: 'bar', 'skip-install': true }, - arguments: ['foo'] - }, { local: this.stubPath }); + this.dummy.composeWith( + 'dumb', + { foo: 'bar', 'skip-install': true }, + { local: this.stubPath } + ); this.dummy.run(function () { assert.equal(this.spy.firstCall.thisValue.options.foo, 'bar'); - assert.deepEqual(this.spy.firstCall.thisValue.args, ['foo']); done(); }.bind(this)); });