Skip to content

Commit

Permalink
Pass default options to composed generators automatically - Fix #745
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Nov 26, 2016
1 parent bddb942 commit d6345f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,19 @@ Base.prototype.run = function run(cb) {
*/

Base.prototype.composeWith = function composeWith(namespace, options, settings) {
settings = settings || {};
var generator;
settings = settings || {};
options = options || {};

// 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)
}, options);

if (settings.local) {
var Generator = require(settings.local);
Expand Down
4 changes: 3 additions & 1 deletion test/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ describe('Base', function () {
resolved: 'unknown',
namespace: 'dummy',
env: this.env,
'skip-install': true
skipInstall: true
});

this.spy = sinon.spy();
Expand All @@ -706,6 +706,8 @@ describe('Base', function () {
setTimeout(function () {
this.dummy.run(function () {
sinon.assert.callOrder(runSpy, this.spy);
assert.equal(this.spy.thisValues[0].options.skipInstall, true);
assert.equal(this.spy.thisValues[0].options['skip-install'], true);
assert(this.spy.calledAfter(runSpy));
done();
}.bind(this));
Expand Down
1 change: 1 addition & 0 deletions test/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ describe('Base (actions/install mixin)', function () {
this.dummy.run();
});
});

describe('#yarnInstall()', function () {
it('spawn an install process once per commands', function (done) {
this.dummy.yarnInstall();
Expand Down

0 comments on commit d6345f7

Please sign in to comment.