Skip to content

Commit d6345f7

Browse files
committedNov 26, 2016
Pass default options to composed generators automatically - Fix #745
1 parent bddb942 commit d6345f7

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed
 

‎lib/index.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,19 @@ Base.prototype.run = function run(cb) {
472472
*/
473473

474474
Base.prototype.composeWith = function composeWith(namespace, options, settings) {
475-
settings = settings || {};
476475
var generator;
476+
settings = settings || {};
477+
options = options || {};
478+
479+
// Pass down the default options so they're correclty mirrored down the chain.
480+
options = _.extend({
481+
options: _.extend({
482+
skipInstall: this.options.skipInstall,
483+
'skip-install': this.options.skipInstall,
484+
skipCache: this.options.skipCache,
485+
'skip-cache': this.options.skipCache
486+
}, options.options)
487+
}, options);
477488

478489
if (settings.local) {
479490
var Generator = require(settings.local);

‎test/base.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ describe('Base', function () {
689689
resolved: 'unknown',
690690
namespace: 'dummy',
691691
env: this.env,
692-
'skip-install': true
692+
skipInstall: true
693693
});
694694

695695
this.spy = sinon.spy();
@@ -706,6 +706,8 @@ describe('Base', function () {
706706
setTimeout(function () {
707707
this.dummy.run(function () {
708708
sinon.assert.callOrder(runSpy, this.spy);
709+
assert.equal(this.spy.thisValues[0].options.skipInstall, true);
710+
assert.equal(this.spy.thisValues[0].options['skip-install'], true);
709711
assert(this.spy.calledAfter(runSpy));
710712
done();
711713
}.bind(this));

‎test/install.js

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ describe('Base (actions/install mixin)', function () {
152152
this.dummy.run();
153153
});
154154
});
155+
155156
describe('#yarnInstall()', function () {
156157
it('spawn an install process once per commands', function (done) {
157158
this.dummy.yarnInstall();

0 commit comments

Comments
 (0)
Please sign in to comment.