From d6345f7984ebf1cb9875e52eec7c86ee413bee5d Mon Sep 17 00:00:00 2001 From: Simon Boudrias Date: Sat, 26 Nov 2016 14:15:08 -0800 Subject: [PATCH] Pass default options to composed generators automatically - Fix #745 --- lib/index.js | 13 ++++++++++++- test/base.js | 4 +++- test/install.js | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 55b880b2..6148bdbd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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); diff --git a/test/base.js b/test/base.js index 20e04257..35ad0000 100644 --- a/test/base.js +++ b/test/base.js @@ -689,7 +689,7 @@ describe('Base', function () { resolved: 'unknown', namespace: 'dummy', env: this.env, - 'skip-install': true + skipInstall: true }); this.spy = sinon.spy(); @@ -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)); diff --git a/test/install.js b/test/install.js index fbf5454b..65e2ada9 100644 --- a/test/install.js +++ b/test/install.js @@ -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();